Loading local csv files from dropdown in Anvil

HI

I want to be able using Uplink load csv files into datagrids- choosing the csv file from a dropdown in the server app. On my local machine I have an uplink program with pandas

df = pd.read_csv(file_name, parse_dates=[
                 date_col], dayfirst=True, infer_datetime_format=True)

and have the datagrid loading working but I would like to load different csv files held in the variable file_name selected from a dropdown.

I can’t get the calls to/from the anvil server to work i.e. I can’t seem to be able to pass the file_name to the local uplink program.

Any help much appreciated

Thanks.

Hi there, it may be helpful to provide the error that you get and the line it occurs on.

Thanks for your response. I am not as far as getting an error message yet. If anyone has an example app like this that would be very helpful. I think I need help with the overall architecture. It is a simple overall architecture I need help with please

On your local machine you could construct a media object which contains your csv, then, pass that media object along to your client (just as you’d pass a media object from the sever to the client).

If you search the forum for “csv media object” or something along those lines, you’ll find many examples that will likely get you started.

Many thanks - will try this

1 Like

Hi

Further to our correspondence yesterday - I think I have found a solution but I have hit an issue.

I have been trying an example of yours Clone of store_dataframe_as_media I believe -

I am getting an error

TypeError: BlobMedia content must be a byte string. at /downlink/anvil/init.py, line 71 called from [ServerModule1, line 35] called from [Form1, line 26]

Can you help me at all please?

Many Thanks

Syd

1 Like

That was due to a recent change.

See this post for the small correction:

That has fixed it many thanks Syd

1 Like