I am still having difficulties using the cache with the new file uploader. This must be really easy but I am stuck since three days…
I have a function that allows the user to either choose a local file or upload her own.
This function passes the path of the local file (if local file chosen) or the StringIO (if upload) object to a the cached function that pd.read_csv reads dataset into a dataframe.
When I load a local csv dataset the cache works, while when I load the file with the file uploader the cache does not work because it sees a “change” in the input. I noticed that the the “number” of the BytesIO changes, so there is a different output from the file uploader.
I take the output of the file uploader (a csv file) and transform it like so:
uploadedFile = uploadedFile.read()
uploadedFile = BytesIO(uploadedFile)
And then I pass the result to a pd.read_csv file.
With the previous file uploader I passed the output of the file uploader that now looks like this
to the cached function and it worked perfectly.
Now if I try to pass the output without transforming it I get this cache error.
I have also tried wrapping the uploaded object in TextIOWrapper
but I get a similar “do not know what to cache” error
I am running in circles. I understand that the solution must be obvious
Many thanks for your help