Colab notebook for uploading CSV or Excel

This might be useful for Anvil newbies on the Free plan looking to upload data to their app. You still basically have to follow the steps here, but this Colab notebook puts a sample uplink script together for you:

To run the example,

  1. Clone this Anvil app: Anvil | Login
  2. Go to Data Tables (Settings in the Beta editor) and check “Auto-create missing columns when adding rows” in the upper right.
  3. Get the Uplink key for your app (making sure it has Server Code permissions) and paste it into the Colab notebook in place of YOUR-UPLINK-KEY.
  4. Click the “Play” icons in the Colab notebook to install anvil-uplink and start running the cell that makes the pandas code available to your app.
  5. Run the Anvil app and click the appropriate file uploader to upload your CSV or Excel data.

p.s. If others have easier ways to do (or demonstrate) this, please share. I was surprised, scanning this article, at how difficult it seemed to simply upload a CSV file to an Anvil Data Table. So I was inspired to see if I could simplify it.

1 Like

Now I’m thinking it might be easier to copy/import data into Google Sheets and pull it in from there

That API is useful for small amounts of data, otherwise I found it deadly slow.

1 Like

I updated this to make it easier to upload the data file: you can now do it via a fileloader in the Anvil app itself. I also added some code that attempts to prevent empty cells (that is, NaN or missing values) from causing issues:
df = df.replace({np.nan: None})

(@mjmare, is this how you resolved your Pandas NaN issue, or is there a better way?)

1 Like

I used df.fillna which amounts to the same but is a tad cleaner IMHO.

1 Like

tried this and got:

anvil.server.NoServerFunctionError: No server function matching "upload_csv_data" has been registered

  • at Form1, line 15

Is it possible you didn’t run the Colab cells (step 4)?