Forum Discussion

nidhi1's avatar
nidhi1
Occasional Contributor
14 years ago

Database table variable with csv file as data source

I have created a DB table variable and have used a csv file as an input to the variable.



However, I see that this table variable is not reading correct values from the csv file. I want it to read one line as the current record and the next line as the next record.



Here is content of my csv file:

OrderDetails

2;15027;S;1;P01543;14;1

1;O06170;S;1;G01962;UK 10;1

3;01543;14;1;E44665;1Size;1;mi Barricade 6;6.5;Narrow

4;14692;XS;1;mi Forum Lo;6.5;Narrow

5;mi Barricade 6;6.5;Narrow

6;V32627;XL;1;mi Barricade 6;6.5;Narrow

7;G4451;UK10;1;mi Barricade 6;6.5;Narrow

8;V1507;XS;1


So, Now I expect that the variable reads 8 lines out of this file. But, it is reading lines starting with 1 and 6 only half way and thereby increasing the total lines in the file from 8 (which is correct) to 10 (which is incorrect).



Could you please help?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The problem is that there is not a constant column length per row.  There are some rows that are longer and some that are shorter.



    Consider a standard relational database, like a table in SQL.  You can't have in a single SQL table two rows in the table with a different number of columns.



    What is the purpose behind the different row lengths?  Is there something you are trying to accomplish by using the CSV file as a DBTable object?
  • nidhi1's avatar
    nidhi1
    Occasional Contributor
    I realized that I wanted to use only one column in the csv file. I have replaced all the semi colons with pipe sign. It seems to be recognizing it correctly now.



    Many Thanks!



    -Nidhi