Forum Discussion
GMcCartney0607 You can try to avoid this by building a schema.ini file that sits in the same path as your csv file. Syntax of file is listed below:\
https://learn.microsoft.com/en-us/sql/odbc/microsoft/schema-ini-file-text-file-driver?view=sql-server-ver17
Specifics about the ini file are also found here as well:
https://support.smartbear.com/testcomplete/docs/testing-with/data-driven/csv-storages.html
- GMcCartney06072 months agoOccasional Contributor
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?
- rraghvani2 months ago
Champion Level 3
You didn't mention that you were using scheme.ini in your original post!?
Have you used the following dialog to create your Data-Driven Loop?
If you haven't used the above dialog, what exactly are you using to read your CSV file?
- GMcCartney06072 months agoOccasional Contributor
Yes, this is how I define the loop variable.
- Hassan_Ballan2 months ago
Champion Level 3
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.
- GMcCartney06072 months agoOccasional Contributor
This looks promising. I will try and report back.