What I’m trying to do:
Take in a excel file, run analysis on a Jupyter Notebook, and output multiple html miles.
What I’ve tried and what’s not working:
Using basic python open and write commands
Code Sample:
# In the app
def file_loader_1_change(self, file, **event_args):
"""This method is called when a new file is loaded into this FileLoader"""
global uploaded_file
anvil.server.call('store_data',file)
uploaded_file = file
def output_html_click(self, **event_args):
global uploaded_file
anvil.server.call("create_html_models", uploaded_file)
#Within python notebook
import anvil.media
@anvil.server.callable
def create_html_models (input_file):
input_file = pd.read_excel(input_file)
htmls = run_analysis(input_file) #each html is in string format
for i in range(0, htmls.len()):
with open('/tmp/output' + str(i) + '.html', 'w+') as f:
f.write(htmls[i])
download(f)
The error I’m currently getting is ValueError: Invalid file path or buffer object type: <class ‘anvil._serialise.StreamingMedia’>. Is this occurring because the input file, even though it’s expected as an Excel file, is actually some form of anvil Media object? If so, how could I convert it? If not, what is the issue?
Thanks