Forum Discussion
83dons
1 year agoHelper III
Date field not pulling into CSV in Python
Hi I am using the following python code to convert a table to a CSV that has inverted commas round every field. It is working apart from for date fields where I get I get "Microsoft.OleDb.Date" inste...
- 1 year ago
I think it is actually easier to just create a new column of type text from the date column then remove the original and rename the new column. That then pulls through ok using the dataset to CSV function.
83dons
1 year agoHelper III
Hi burakkaragoz if I add the following into Power BI I get a blank field for date of birth.
import pandas as pd
dataset['Date of Birth'] = pd.to_datetime(dataset['Date of Birth'], errors='coerce')
dataset.to_csv(
r"REMOVED",
sep=',',
quotechar='"',
quoting=1,
index=False,
na_rep='',
encoding='utf-8'
)I notice if I change the power BI column from Date type to Date/Time then run the csv function that pulls through but then its in the wrong format - 1975-11-25T00:00:00.0000000 it needs to be 25/11/1975
Any ideas?
83dons
1 year agoHelper III
I think it is actually easier to just create a new column of type text from the date column then remove the original and rename the new column. That then pulls through ok using the dataset to CSV function.