r/PyScript • u/ShotgunPayDay • Jul 01 '22
Created a demo using file upload and Pandas as a spreadsheet scrubber.
I didn't really see an example of PyScript where you upload CSV files, scrub them together, then download the output. This is something where I think PyScript really shines as in a previous job I was delivering a lot of spreadsheet/text file scubbers for various departments. The users hated downloading newer versions of the PyInstaller.exe and then get upset when the problem still persisted when they don't download the new version :(.
With PyScript I can simply spin up an NGINX server where they can get an always up to date version of the scrubber without PyInstaller/Tkinter and have a nice web interface. My only complaint would be that I used Javascript for the final file download, but I couldn't find an example of how to do that through PyScript. This example is completely self contained so nothing is sent to any backend server as you'll see from the code.
I would have also split main.py into main.py and functions.py but there is an issue (security?) with NGINX not being able to load the functions.py file.
<py-env>
- paths:
/functions.py
</py-env>As a proof of concept I made a little spreadsheet scrubber and have a live example self hosted here: https://mattascale.com/pyscript/
More information/notes and project is on my Gitlab here in csv_scrubber folder: https://gitlab.com/figuerom16/pyscript
I hope this helps someone get started.
2
u/metaperl Jul 02 '22
Compare with the gradio code in this article
https://www.reddit.com/r/Python/comments/vou3iw/create_web_uis_for_python_apis_and_ml_models/
1
u/metaperl Jul 01 '22
It certainly sounds like you have eliminated install headaches but your task seems better suited for a more mature pure python web app solution, probably gradio. Consult my guide for details https://docs.google.com/document/d/13da40zzfEZmA-LfsfISPmILpbmgpLZHJJVNdQmhT7Gs/edit?usp=drivesdk
2
u/BurningSquid Jul 01 '22
This is an awesome project I'm going to check it out in more detail. Thanks for posting!
1
u/metaperl Jul 01 '22
A medium article was posted here today showing how trivial this is with gradio. You just define an input and return output. Done.
1
u/metaperl Jul 02 '22
The Gradio File component can be used for input and output. I was going to fork your code and do it but the model and view code is do intertwined that it would take me awhile to separate model logic from view logic
Scroll to the bottom of this page https://gradio.app/docs/