Martin
Martin2w ago

How to process the uploaded file with a python script?

I'm just starting to play with windmill. A a first try, I want to create a simple demo app which has one file input component and one table. After a user uploads a CSV file, I want to use python script to process the file and show it with the table. By reading the documentation, I know there's a onFileChange event handler after a file is uploaded, but I have no idea how to write python code to bind to it. The right-side panel of file-input showed (as attached): No Event handlers on file change No components to recompute.
No description
6 Replies
rubenf
rubenf2w ago
once you upload you will have a result in the output of that component use as input of another thing an expr that refers to that output and bam it's done automatically. It's a reactive framework
Martin
MartinOP2w ago
@rubenf I did see the result of the uploaded file on the left panel in App Editor. However, I still have no idea how to use python script to get the uploaded file and do some data transformation and finally show the transformed data with ag grid. Is there any step-by-step guide for this use case?
rubenf
rubenf2w ago
use it as input of your python script (define an arg, then connect it to that output), then use the wmill helpers to load it from s3
Martin
MartinOP2w ago
@rubenf My python script seems not getting executed after the file is uploaded. Also, I'm trying to access the uploaded file as binary data encoded in base64, not s3. Can you provide any sample python code?
rubenf
rubenf2w ago
here is a mini app you can import:
Martin
MartinOP2w ago
@rubenf It works. Thank you !

Did you find this page helpful?