CsvHelper
CsvHelper copied to clipboard
schema.ini for CsvDataReader
I have been using CsvDataReader for big csv files but it doesn't seem that a schema.ini is considered when it exists.
The schema.ini file is really helpful to define the datatypes of the columns which are going to be loaded into the datatable such as
[example.csv]
ColNameHeader=True
Format=CSVDelimited
DecimalSymbol=.
DateTimeFormat=yyyy-mm-dd hh:nn:ss
Col1=MyCol1 Text
Col2=TransmissionDate DateTime
Col3=Lat Double
Col4=Lon Double
For the time being when I use CsvDataReader, all the columns are text.
Thank you very much for your help.
Sylvain
You can pass a DataTable into the CsvDataReader constructor. You could use that to generate a proper DataTable, then pass that to CsvDataReader to read in. The types should be ok then.