This code located in pg2.py
def parse_contents_1(contents, filename, date, n_clicks_b):
global nfile
content_type, content_string = contents.split(',')
decoded = base64.b64decode(content_string)
try:
if 'csv' in filename:
# Assume that the user uploaded a CSV file
df = pd.read_csv(
io.StringIO(decoded.decode('utf-8')), skiprows=7)
nfile[filename] = df.to_dict('records')
elif 'xls' in filename:
# Assume that the user uploaded an excel file
df = pd.read_excel(io.BytesIO(decoded), skiprows=7)
nfiles[filename] = df.to_dict('records')
# return nfile
except Exception as e:
print(e)
return html.Div([
'Yüklədiyiniz fayl formatı dəstəklənmir.'
])
fName = filename.split('_')[0] + ' ' + filename.split('_')[1]
return dbc.Col([html.Div([
html.H5(children = [fName], id= {"type":"dynamic-name", "index": n_clicks_b }), dcc.Slider(id={"type":"id_1", "index": n_clicks_b },step=1)])], width = 5)
@callback([Output('output-dataBS', 'children'),
Output('store-data-BS', 'data')],
[Input('upload-data-BS', 'contents'),
Input("dynamic-add-filter", "n_clicks"),
State('upload-data-BS', 'filename'),
State('upload-data-BS', 'last_modified'),
State("output-dataBS", "children")])
def update_output(list_of_contents, n_clicks_b, list_of_names, list_of_dates, children_bs):
if list_of_contents is not None:
new_children = [
parse_contents_1(c, n, d, n_clicks_b) for c, n, d in
zip(list_of_contents, list_of_names, list_of_dates)]
return children_bs.append(new_children), nfiles
raise PreventUpdate
@callback(
Output({'type': 'id_1', 'index': MATCH}, 'min'),
Output({'type': 'id_1', 'index': MATCH}, 'max'),
Output({'type': 'id_1', 'index': MATCH}, 'marks'),
Input({'type': 'dynamic-name', 'index': MATCH}, 'children'),
Input({"type":'store-data-BS', "index":MATCH}, "data"),
Input("slider-date", 'value'),
State({'type': 'store-data-BS', 'index': MATCH}, 'id'),
State({'type': 'dynamic-name', 'index': MATCH}, 'id'),
)
def display_output(children_nm, t_data, d_value, id_bs, id_nm):
for k, v in t_data.items():
if "XXXXXXX" in k:
dbts = pd.DataFrame.from_dict(v)
gdfs = pgd.GeoDataFrame(dbts)
snx = str(np.datetime64(unixToDatetime(d_value)))
dr_df = gdf[gdf["Tarix"].astype('datetime64[D]') == snx]
in_min = dr_df.index.min()
in_max = dr_df.index.max()
range_dt = range(in_min, (in_max + 1), 1)
kl = pd.to_datetime(dr_df["Tarix"])
mrk_t = getMarks_times(kl, range_dt)
return in_min, in_max, mrk_t
But this code located in my app.py script
dcc.Store(id={"type":'store-data-BS', "index": pages.pg2.n_clicks_b},storage_type="session")
When I run my application and start to upload my data to the dcc.Store but
I get this error code:
AttributeError: module ‘pages.pg2’ has no attribute ‘n_clicks_b’
I think I can solve this error by creating class.
Please, if you have any solution for it, help me.
Thanks