|
|
|
@ -117,25 +117,17 @@ def parse_contents(contents, filename):
|
|
|
|
|
Input('upload-data', 'contents'),
|
|
|
|
|
Input('upload-data', 'filename'),
|
|
|
|
|
])
|
|
|
|
|
def csv_to_json(contents, name):
|
|
|
|
|
def csv_to_json(contents, filename):
|
|
|
|
|
if contents is not None:
|
|
|
|
|
return parse_contents(contents, name)
|
|
|
|
|
try:
|
|
|
|
|
json_data = parse_contents(contents, filename)
|
|
|
|
|
except:
|
|
|
|
|
json_data = json.dumps({'error': filename})
|
|
|
|
|
|
|
|
|
|
return json_data
|
|
|
|
|
|
|
|
|
|
@app.callback(Output('output-data-upload', 'children'),
|
|
|
|
|
[Input('json-storage', 'children')])
|
|
|
|
|
def read_json_data(json_data):
|
|
|
|
|
if json_data is None:
|
|
|
|
|
elements = html.Div([
|
|
|
|
|
dcc.Graph(),
|
|
|
|
|
html.Div([
|
|
|
|
|
html.Div([dcc.Graph()], className='six columns'),
|
|
|
|
|
]),
|
|
|
|
|
html.Div()
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
return elements
|
|
|
|
|
|
|
|
|
|
def update_objects(json_data):
|
|
|
|
|
info = json.loads(json_data)['info']
|
|
|
|
|
df = pd.read_json(json.loads(json_data)['timeseries'], orient='table')
|
|
|
|
|
ts = []
|
|
|
|
@ -229,6 +221,38 @@ def read_json_data(json_data):
|
|
|
|
|
return elements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.callback(Output('output-data-upload', 'children'),
|
|
|
|
|
[Input('json-storage', 'children')])
|
|
|
|
|
def read_json_data(json_data):
|
|
|
|
|
if json_data is None:
|
|
|
|
|
elements = html.Div([
|
|
|
|
|
dcc.Graph(),
|
|
|
|
|
html.Div([
|
|
|
|
|
html.Div([dcc.Graph()], className='six columns'),
|
|
|
|
|
]),
|
|
|
|
|
html.Div()
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
elif json.loads(json_data)['error']:
|
|
|
|
|
filename = json.loads(json_data)['error']
|
|
|
|
|
elements = html.Div([
|
|
|
|
|
dcc.Graph(figure={
|
|
|
|
|
'layout': {
|
|
|
|
|
'title': 'Error reading {}'.format(filename)
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
html.Div([
|
|
|
|
|
html.Div([dcc.Graph()], className='six columns'),
|
|
|
|
|
]),
|
|
|
|
|
html.Div()
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
elements = update_objects(json_data)
|
|
|
|
|
|
|
|
|
|
return elements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
port = 8050
|
|
|
|
|
wb.open('http://localhost:{}'.format(port))
|
|
|
|
|