請在不喜歡這個問題之前問我你不明白的地方大家好,我有數據生成程序,它會做很多計算,所以我不能在這里粘貼我的整個程序,所以只談論我的程序 程序的所有計算都從閱讀文件,所以當我在“選擇文件”選項的網頁中選擇多個 CSV 文件時,我需要驗證所有 csv 文件的列號(應該相同),列標題名稱也應該匹配..我編寫的程序是像這樣:from flask import Flask, render_templateimport osimport csvimport pandas as pdimport numpy as npapp = Flask(__name__)APP_ROOT = os.path.dirname(os.path.abspath(__file__))@app.route("/")def index(): print("Loading the root file") return render_template("upload.html")@app.route("/upload", methods=['POST'])def upload(): target = os.path.join(APP_ROOT, 'input/') print("target-",target) if not os.path.isdir(target): os.mkdir(target) for file in request.files.getlist("source_fileName"): print("file-",file) filename = file.filename print("filename-",filename) destination = "/".join([target, filename]) print("destination-",destination) file.save(destination) print("file>",file) global tempFile tempFile = destination print("tempFile - " + tempFile) return redirect("/compute", )def compute(): readerForRowCheck = pd.read_csv(tempFile) for row in readerForRowCheck: if (len(row) != 8): return render_template("Incomplete.html") headerColumn1 = row[0]; headerColumn2 = row[1]; headerColumn3 = row[2]; headerColumn4 = row[3]; headerColumn5 = row[4]; headerColumn6 = row[5]; headerColumn7 = row[6]; headerColumn8 = row[7];
添加回答
舉報
0/150
提交
取消