Forum Discussion

vladm's avatar
vladm
Occasional Contributor
13 years ago

CSV Driver doesn't see columns of csv file

Hi All, help me please to find the reason of such problem:


Dashboard_drv = DDT.CSVDriver("C:\\Documents and Settings\\Administrator\\Desktop\\FILES AFTER UPLOAD to COMPARE\\Dashboard.csv");

var Col_Num = Dashboard_drv.ColumnCount; 

var Col_Name, i;

Log.Message(Col_Num);


for ( i=0; i < Col_Num; i++ )

{

Col_Name = Dashboard_drv.ColumnName(i);

Log.Message(Col_Name);

 }



After executing this code CSV driver said that  
Col_Num = 1 but file contains 23 columns.


Any ideas?


Interesting fact: This code worked successfully on physical machine but after moving my Test Complete to virtual machine i got such problem. 


Maybe some differences in Regional and language options???




Thanks.


4 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Vova,



    From the Using CSV Files as Data Storages topic:

    The format of the CSV file is determined by using a schema information file, named Schema.ini, and located in the same folder as the CSV file. Schema.ini can keep information about several files and for each file it provides data for the general format of the file, field names and field types, used character set, delimiter character, and a number of other data characteristics.

    ...

    When the Schema.ini file is not found, the format of the CSV file is defined by the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text registry settings. For instance, the delimiter character is specified by the Format key and can have one of the following values: TabDelimited, CSVDelimited, Delimited(custom_character), FixedLength.


    So, most likely, your physical and virtual machines have different CSV delimiters specified in the registry.
  • vladm's avatar
    vladm
    Occasional Contributor

    Hi Helen.


    You were right. My VM hasn't HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\JET directory in the registry (in comparison with my physical machine where "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text" is present).


    But i came across a new problem: how i can to include missing values into registry? When i tried to import appropriate registry folder ==> my license failed.


    What can i do? Maybe reinstalling of Microsoft Office will help? But I'm afraid that any changes in the registry can kill my license again, and it's too many time could be missed to recreate license again.



    Thanks in advance. 

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Vova,



    The easiest solution that doesn't require any changes in the registry is to create the Schema.ini file for your CSV file and place it in the same folder as the CSV file. In this case, TestComplete will use CSV format settings from the Schema.ini file rather than from the registry.



    For an example of Schema.ini contents, check out Using CSV Files as Data Storages.