# Datatable export\_csv

**URL:** <https://community.plotly.com/t/datatable-export-csv/62704>\
**Category:** Dash Python\
**Created:** [April 5, 2022, 7:11am UTC](https://community.plotly.com/t/datatable-export-csv/62704 "2022-04-05T07:11:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SUN](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SUN](https://community.plotly.com/u/SUN)\
**Post date:** [April 5, 2022, 7:11am UTC](https://community.plotly.com/t/datatable-export-csv/62704/1 "2022-04-05T07:11:12Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/8/5/858cb95827bf23e62e149bf4afcc407bc3c36051.png)

Thx a lot for your help in advance ! !

Method1

```auto
@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:

```auto
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
    )])

```

---

<div class="post-metadata">

**Author:** ![HarishOsthe](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/harishosthe/32/9949_2.png) [@HarishOsthe](https://community.plotly.com/u/HarishOsthe)\
**Post date:** [April 5, 2022, 8:01am UTC](https://community.plotly.com/t/datatable-export-csv/62704/2 "2022-04-05T08:01:01Z")

</div>

Hi, @SUN Try this way.

```python
@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",sep = ';', index = False, header=True, encoding='utf-8')

```

---

<div class="post-metadata">

**Author:** ![SUN](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@SUN](https://community.plotly.com/u/SUN)\
**Post date:** [April 6, 2022, 8:54am UTC](https://community.plotly.com/t/datatable-export-csv/62704/3 "2022-04-06T08:54:11Z")

</div>

It works! Thx a lot for you help!
