Forum Discussion

sergeys's avatar
sergeys
Contributor
9 years ago
Solved

Why Dots are replaced by '#' when getting column names from csv file

Does anybody know, why "." is replaced by "#" when getting column names from CSV file?

 

I have WPF grid which is empty by default and it is possible to add columns with names as specified in Schema.ini:

[Myfile.csv]

Format=CSVDelimited

ColNameHeader=True
MaxScanRows=0

Col1=Product Text
Col2="Price Abs. Change" Double

 

And I have the following function to add these columns which is working OK: 

function PopulateColumnsFromFile(FileName) {

var CSV = DDT.CSVDriver(Project.Path + "\\Data Files\\" + FileName + ".csv");
var i = 0;
for (i = 0; i < CSV.ColumnCount; i++) {
AddColumn();
ChooseColumn(CSV.ColumnName(i).replace("#", "."));
}
DDT.CloseDriver(CSV.Name);
}

 

 

So initially CSV.ColumnName(i) brings me "Price Abs# Change" instead of "Price Abs. Change".

The question is why "." sign is seen like "#" sign, and I have to use '.replace("#", ".")' to get correct value of column name? Any links to the answer would be appreciated.

  • Period is not a valid character in a column name.  It seems that a valid name should start with [a-zA-Z_@#] and remaining letters could also include [0-9]  (but I notice in practice that a digit can start a column name).  I would have thought that names enclosed in double quotes could contain any character but apparently not...

     

    Can't find any authoritative document to say what the driver is expecting for a field name.

3 Replies

  • Period is not a valid character in a column name.  It seems that a valid name should start with [a-zA-Z_@#] and remaining letters could also include [0-9]  (but I notice in practice that a digit can start a column name).  I would have thought that names enclosed in double quotes could contain any character but apparently not...

     

    Can't find any authoritative document to say what the driver is expecting for a field name.

    • sergeys's avatar
      sergeys
      Contributor

      Thanks for response, it is really strange that we couldn't find any answer regarding it, but it is not really blocker anyway.

      • joseph_michaud's avatar
        joseph_michaud
        Moderator

        I should point out that this is not a TestComplete restriction but rather of the various database drivers.  Web search on this shows it to be a more generic issue.  I couldn't find anything definitive relating to the Jet driver at the Microsoft site about this.