What I’m trying to do:
I have a pickled pandas dataframe stored on a remote (non-anvil) server. In my anvil app I download the file via ftplib Anvil server-side. I then want to unpickle the file so it becomes a pandas df again, from which I can extract timeseries data to plot.
What I’ve tried and what’s not working:
see code below
Code Sample:
with open('play.pkl', 'wb') as server_mdfpd:
ftp.retrbinary('RETR play.pkl', server_mdfpd.write)
print (server_mdfpd)
with open("play.pkl", "rb") as file:
unpickled_df = pd.read_pickle(file)
The print statement gives
<_io.BufferedWriter name=‘play.pkl’>
The error I get is
UnsupportedOperation: read
at /home/anvil/.env/lib/python3.10/site-packages/pandas/io/pickle.py:202
Running the exact same code in PyCharm in my local .venv works
I also tried just about all of the suggestions you get when you search Anvil Q&A with “Data Files”
What am I doing wrong?
BTW, putting the df into an Anvil data.table won’t work for me, since the file is modified externally (outside the current app), but read only once in a while.
Thanks for any pointers in the right direction (I am on the free plan so far).
EDIT: if I change with open(‘play.pkl’, ‘wb’) as server_mdfpd: to with open(‘play.pkl’, ‘rb’) as server_mdfpd: I get
ModuleNotFoundError: No module named 'numpy._core.numeric'
Trying to install numpy._core.numeric I get
No solution found when resolving dependencies:
╰─▶ Because numpy-core-numeric was not found in the package registry and
you require numpy-core-numeric, we can conclude that the requirements
are unsatisfiable.