-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loading a local *.csv file #8
Comments
Came here with the exact same question. I could see perhaps one way would be to deploy the CSV files alongside the others and the pass an URL to read_csv; however, that would mean the code for Shiny Live would need to be different to the code for client/server deployment. So then the question would be: is there a way to tell at runtime whether you are using Shiny Live vs client/server? And a way to tell what the base URL is when running with Shiny Live? |
What do you mean by "deploy the CSV files alongside the others"? Where are you going to deploy it and what URL are you going to use? Note that using a URL to get a file is also a bit tricky as you need to import pyodide.http library and use it to make a request.
P.S. |
Yes, your example is along the lines of what I was thinking, but ideally without hard-coding the entire URL; the code shouldn't have to depend on where the final deployment happens. Interesting that the data is going in app.json. That certainly suggests there should be a way to access it. And explains why my app.json is 130MB. |
Ah, I got it working; I thought this would be a no-op but its the magic that is needed: from pathlib import Path
dataset = pd.read_csv(Path(__file__).parent / 'survey.csv') |
Worked for me also. |
I couldn't understand from documentation how can I make a local file accessible to the application, so that it would be possible to read_csv and do things like that?
Should I copy it to some location in
shinylive
folder? An what path should I provide for the script to work?Some files in project directory can be accessed by the py-shiny app which works fine, but shinylive app gives file_not_found_error if I build a shinylive app from exactly the same project.
The text was updated successfully, but these errors were encountered: