Forum Discussion
I have a schema.ini, but it only specifies the delimiter. Are you saying that I need to specify the field type (string) and length so that TC it will not convert and drop the leading zero for the quoted strings?
Forcing the “Area” column to stay as text
TestComplete uses the OLE DB Text driver under the hood to read CSVs, and by default that driver “guesses” each column’s data type by scanning the first few rows. If it thinks a column is numeric, it will strip leading zeros. You can override that behavior in schema.ini by explicitly declaring each column as Text.
Update your schema.ini, it should look something like this:
[YourFileName.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=0
; force all three columns to be treated as text
Col1=ID Text
Col2=Area Text
Col3=Name Text
- Format=CSVDelimited tells the driver it’s a comma-delimited file.
- ColNameHeader=True makes the first row your header.
- MaxScanRows=0 forces the driver to scan all rows (not just the first 8) when inferring types.
- ColN=… Text explicitly sets that column to text, preserving leading zeros.
💬 If a response helped you out, don’t forget to Like it! And if it answered your question, mark it as the solution so others can benefit too.
- GMcCartney06075 months agoOccasional Contributor
This looks promising. I will try and report back.
- GMcCartney06075 months agoOccasional Contributor
That didn't do anything. Do I need to uncheck the box in the definition that says to override defaults?
- GMcCartney06075 months agoOccasional Contributor
I can't do that because it requires additional drivers. I have implemented a workaround to pad the values before using them.
Wasteful use of CPU, but works.