Search code examples
csvschemaschema-design

How to make a schema.ini - help needed


Morning,

I am new to this so just need a quick hand on how to create a schema.ini file.

I need to have 2 cols, one for the product sku, which is a string value. And one for the price, which is a decimal value.

I currently have the following in my schema.ini, but i am unsure how what they should be, i have done the sku as Text, but unsure about the decimal one.

[test.csv]
ColNameHeader=False
Format=CSVDelimited
DateTimeFormat=dd-MMM-yyyy
Col1=sku Text
Col2=amzPrice 

Solution

  • As you are using JET I would suggest the most appropriate datatype is Currency. This is an 8-byte decimal value, with a range -922,337,203,685,477.5808 to 922,337,203,685,477.5807. I would discourage the use of Double for storing decimal numbers, as it is imprecise. See this SO question for example.

    If you only have to have a resolution of pence/cent, then you can store your currency values as an integer datatype (e.g. Long) and treat them as pence, not pounds. This ensures you never have to worry about rounding errors, but you cannot have fractions of a pence.

    Microsoft maintain a list of supported datatypes is here. You can find definitions for the JET datatypes here.