nephilimrising nephilimrising - 1 month ago 10
Python Question

Python to excel is there a way to set data types

I have info that I need to export now to excel file. Is there a way to set data types in columns from python? For example I need one of the columns to be with dates in US format only.

Answer

There are pretty much two options for getting data into excel.

  1. Save the data as a csv with common data formats and use the excel importers to auto-recognize and set the datatypes.

  2. Use a python library that can write excel files and set the datatypes directly.

For the 2nd option XlsxWriter is an excellent library that can write excel files and set the datatypes and formats for each cell.