Hello all, I wanna to ask some details related to datatable. I would like to export a csv file with the separators as " ; ", but not " , ".
Actually, I’ve read the references below and tried 2 different ways. But it seems that it does not work.
Thx a lot for your help in advance ! !
Method1
@callback(
Output("download-dataframe-csv", "data"),
Input("btn-csv", "n_clicks"),
prevent_initial_call=True,
)
def func(n_clicks):
df.to_csv(r'a.csv', sep = ';', index = False, header=True, encoding='utf-8')
return dcc.send_data_frame(df.to_csv, "a.csv")
Method2:
return html.Div([dash_table.DataTable(
columns=[{"name": i, "id": i} for i in df.columns],
data = df.to_dict('records'),
export_format='csv', #xlsx
export_headers='display',
merge_duplicate_headers=True
)])