✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Exporting DataTable as csv bug

I am building a tool that creates cumulative loss triangles by querying a SQL database. After pulling the data I create the triangle tables using pandas Dataframe. The code snippets to create the DataTable in dash are:

triTable = tri.to_dict(‘rows’)
triColumns = [{‘name’: i, ‘id’: i} for i in tri.columns]
return dash_table.DataTable(data=triTable, columns=triColumns, export_format=‘csv’)

The DataTable looks exactly how I want!

When I go to export the table as a csv the resulting file has copies of the column names that are empty.

Printing the returned DataTable looks like:

DataTable(columns=[{‘name’: ‘Effective Year’, ‘id’: ‘Effective Year’}, {‘name’: 3, ‘id’: 3}, {‘name’: 15, ‘id’: 15}, {‘name’: 27, ‘id’: 27}, {‘name’: 39, ‘id’: 39}, {‘name’: 51, ‘id’: 51}, {‘name’: 63, ‘id’: 63}, {‘name’: 75, ‘id’: 75}, {‘name’: 87, ‘id’: 87}, {‘name’: 99, ‘id’: 99}, {‘name’: 111, ‘id’: 111}, {‘name’: 123, ‘id’: 123}, {‘name’: 135, ‘id’: 135}, {‘name’: 147, ‘id’: 147}, {‘name’: 159, ‘id’: 159}], data=[…], export_format=‘csv’

Not sure if this a bug in dash or an issue with excel. Any help is appreciated!