The Schema.ini file has different options, you can read about it here.
Schema.ini File (Text File Driver)
You can specify, among other things, the Column Data Type and also the decimal separator. For example, a schema that defines 4 Columns where:
ColNameHeader=True
: The data file contains the Columns definition
Format=Delimited(;)
: The Columns are separated by a semicolon
DecimalSymbol=,
: The decimal separator is a comma
Col(N)=ColumnName TYPE [WIDTH] [#]
: the Columns' Name and Type and, optionally, the width of the Column. The width value ([#]
) is mandatory.
If the Columns may contain a currency symbol that is not the System default's, specify the Currency format. For example, using the Euro €
Symbol:
CurrencySymbol=[Symbol]
: the Currency symbol used in the data file.
CurrencyPosFormat=[N]
: the Symbol position for positive values. This can be one of these 4 values:
0 = €1,1 1 = 1,1€ 2 = € 1,1 3 = 1,1 €
CurrencyNegFormat=[N]
: same as above, but many more positions can be specified. See the previously linked documentation for a list of possible values
CurrencyDigits=[N]
: the number of decimal digits used for Currency
CurrencyThousandSymbol=[Symbol]
: the Thousands separator Symbol
CurrencyDecimalSymbol=[Symbol]
: the Decimal separator Symbol
The CharacterSet specifies what Encoding the CSV file is using. Standard values are:
ANSI
(local CodePage), OEM
, Unicode
. Other Encodings must be specified using their CodePage. For example, UTF-8 needs to be specified as a CodePage 65001
.
All available CodePages in a System are listed in this Registry Key:
HKEY_CLASSES_ROOT\MIME\Database\Charset
With the this CSV content:
ID;Description;Quantity;FloatValue;Price
1;String 1;100;10,56;€10,79
2;String 2;101;12,72;€200,34
3;String 3;33;100657,72;€0,98
A Schema.ini file can be as follows:
[filename.csv]
ColNameHeader=True First row is the Columns Header
MaxScanRows=0 No auto-detect Column Type
CharacterSet=65001 UTF-8 file Format
Format=Delimited(;) Columns delimiter
DecimalSymbol=, Decimals separator
NumberLeadingZeros=1 Below 1 values leading zeros (0,12)
CurrencySymbol=€ Currency symbol (if present)
CurrencyPosFormat=0 Currency positive format: €1,1
CurrencyNegFormat=1 Currency negative format: -€1,1
CurrencyDigits=2 Number of Decimal digits
CurrencyThousandSymbol=. Thousands separator
CurrencyDecimalSymbol=, Decimal separator
Col1=ID Long |-- Columns definition
Col2=Description Text WIDTH 50 |
Col3=Quantity Integer |
Col4=FloatValue Double |
Col5=Price Currency |
[otherFilename.csv]
ColNameHeader=True
MaxScanRows=25 | Auto-detect the data type, using 25 rows as sample
CharacterSet=ANSI
Format=Delimited() | Standard delimiter: (,)
In any case, I suggest to get a library as CsvHelper