亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 python Flask 中對兩個或多個 CSV 文件進行驗證

如何在 python Flask 中對兩個或多個 CSV 文件進行驗證

慕哥9229398 2021-09-28 16:11:41
請在不喜歡這個問題之前問我你不明白的地方大家好,我有數據生成程序,它會做很多計算,所以我不能在這里粘貼我的整個程序,所以只談論我的程序 程序的所有計算都從閱讀文件,所以當我在“選擇文件”選項的網頁中選擇多個 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];
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 254 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號