Is there a function for taking interactive user input for output directory or file path? In this doc,
dcc.Upload lets the user select input file through the file browser. I was hoping to find something similar to that for specifying output directory.
Ping everyone …
Following up on my question.
Can you elaborate a bit on what you are trying to accomplish?
import base64, io
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate
import pandas as pd
from os.path import join as pjoin
app = dash.Dash(__name__)
app.layout = html.Div([
# input file is selected from a dialogue box
'Drag and Drop or ',
'Enter output directory ',
# FIXME can output directory also be selected from a dialogue box ?
if not raw_contents:
_, contents = raw_contents.split(',')
decoded = base64.b64decode(contents)
df = pd.read_csv(io.StringIO(decoded.decode('utf-8')))
return 'File loaded, saving ...'
app.run_server(debug=True, port=8050, host='localhost')
Are you trying to automatically write file’s to the users PC? Does one of the cases below resemble your use case?
- Dash app runs on PC1
- User A uses browser on PC2 to connect to the dash application
- User A uses dcc.Upload component to upload data. The data is uploaded to the browser memory on PC2
- Upload process triggers a callback on the server. The data is sent from browser memory of PC2 to the server on PC1. Dash app does some computations on the data.
- Used A wants to get the processed data.
Possible solution: Download button / download action. It is not possible to save the data automatically to the user’s computer (PC2) without some very special arrangements (usually server has zero access to user’s PC).
- Dash app runs on PC1
- User A uses browser on the same computer, PC1 to access the dash app
- User A uses dcc.Upload component to upload data
- Some callbacks are triggered and computations are done based on the data
- User A wants to get the processed data
Possible solutions: Download button or saving data automatically to the PC1.
Are you trying to automatically write file’s to the users PC?
But thanks for the summary @np8. I think if you slightly rephrase the last line, that would be more useful–
saving data by Python code to the PC1.
I sensed my answer from your summary.