Ways to speed up csv import to data table?

Just to add, if you’re using the Accelerate Tables beta then there’s a new api for doing this much faster.

app_tables.my_table.add_rows(list_of_dicts)

It can take any iterable of dictionary like objects.
And for a pandas dataframe your code might look like

def store_upload_data(file):
    with anvil.media.TempFile(file) as file_name:
        if file.content_type == 'text/csv':
            df = pd.read_csv(file_name).dropna()
            app_tables.upload_data.add_rows(df.to_dict(orient="records"))

So rather than doing 1000 server calls you do a single server call :smile:

6 Likes