CSV to Anvil Data Tables For Beginners with Full Example App



I see many new anvil users struggling to load data sets into the data tables for the first time without having an example of how to avoid abusing the free resources while still loading your use case sample data under the 30 second limit provided by the server modules.

So I created this full example app.
Feel free to clone it and use it for testing, reference, ideas, or anything else.

It is not fast. That’s kind of the point. This is full starting off point that works with all the code examples imbedded in it.
If you want to add or optimize it go ahead!

Also, if you think you have something cool to add to it, feel free to mod it and re-post your own clone link. If I see good ones I will add them to the bottom of this top post if possible.

I have done as much work as I wish to do on this, feel free to try and break it and post the results if you like.

A few things:

  1. CSV Browser only processing:

The python csv library is not implemented yet in Skulpt so…
The CSV is processed in the browser using javascript from here:
GitHub - evanplaice/jquery-csv: A jQuery CSV parser plugin. Battle Tested | Optimized | 100% IETF RFC 4180 Complete

I put it directly into native libraries so you can see the JavaScript for yourself. I don’t write in javascript, feel free to replace it with whatever you want that does the job.

  1. No Module needed - but Basic Python Free is gently supported image

This was made to use no sever modules at all, but you can use the basic free python sever module without it timing out. Whether you decide to load so much data that it kicks you in the pants because you are slowly grinding close to the limit for so long is really up to you. Be nice. :face_with_monocle:

  1. Data Tables

Make sure this is checked if you are starting a table from scratch: image
Whatever you name your table will be used by the app. If you want the browser to do the table writing, you are going to have to give the client access to it. Please Remember to remove this access if you don’t want it granted forever.

  1. Custom Parsing

There is support for adding your own custom parsing python classes. If any of what I just wrote makes sense to you you should be able to figure out how they are implemented.
The current date and datetime column parsing are written to default to how the Anvil IDE exports a CSV file.
There is no such thing as ‘standard’ CSV data, so for example if your dates don’t look like a python .strptime() format of "%Y-%m-%d" and you do not change the default - well you’re gonna have a bad time. :face_with_head_bandage:

  1. It just loads data to Anvil Data Tables.

This does not do anything else, It just loads data. if you load the same data twice, you will get a table with twice the data. There are no checks, for anything, duplicates etc.
If you want any of that, here is just a place to start!


Have fun and keep on number crunching. :woman_technologist: :man_technologist: :robot: :cowboy_hat_face: :wave:



I was about to replicate this app exactly until I found this post. Look forward to going through it :slight_smile: