I just updated the new uploader and now I get an error I did not get before when I try to pass my uploaded csv file to a cached function.
I looked at the documentation of the file uploader and tried to convert the uploaded object in something else with StringIO(uploaded_file.decode(“utf-8”)) and with text_io = io.TextIOWrapper(uploaded_file) but I still get the caching error.
I assume I need to add something to my cache function. I have tried @st.cache(hash_funcs={StringIO: StringIO.getvalue}) and others but it does not work.
Being trying to solve this for some time. Help is really appreciated Great product!
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:
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.