CsvHelper icon indicating copy to clipboard operation
CsvHelper copied to clipboard

schema.ini for CsvDataReader

Open sylvaincaillot opened this issue 3 years ago • 1 comments

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

sylvaincaillot avatar Sep 15 '22 10:09 sylvaincaillot

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.

JoshClose avatar Oct 04 '22 14:10 JoshClose