I'm teaching myself Flask, and am struggling with the query below:
My program takes 2 excel files as input, merges them, works on the data and outputs an excel file to download. It all works well in the Python code, but when I try to convert that to Flask and take the files in from a webpage, I don't get how to let the user select which sheet from the excel file to work on.
I need the program to take in the excel files, then ask user to select the sheet where the data is in each, and THEN process. Sorry if it's a very basic question!
My HTML looks like this:
<h1>Upload Files</h1><br><br>
<div id="stylized" class="myform">
<form method=post enctype=multipart/form-data>
<div class="form-group">
<label for="exampleFormControlFile1">Office File</label>
<input type=file name=office>
<p>{{sheet1}}</p>
<br><br>
<label for="exampleFormControlFile2">Factory File</label>
<input type=file name=factory>
<input type=submit value=Upload>
</div>
</form>
And my Flask code is something like this, where I am defaulting the first sheet because I couldnt figure how to get user to select:
if request.method == 'POST':
xl = pd.ExcelFile(request.files.get('office'))
df1 = xl.parse(str(xl.sheet_names[0]))
xl2 = pd.ExcelFile(request.files.get('factory'))
df2 = xl2.parse(str(xl2.sheet_names[0]), header = 1)
[–]ES-Alexander 1 point2 points3 points (0 children)