Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
erichshiino
Partner - Master
Partner - Master

Simple CSV load (?)

Hi,

I used wizard to load a simple csv file. The catch is a blank field name. QV generated the following script which fails..

LOAD ,

     Field1,

     Field2

FROM

testLoad.csv

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

The CSV content is just like this ( there is no name for the first field)

;Field1;Field2

abc;1;2

xyz;1;2

I could load it like this, but I would need to rename the @X to the real field name and my real CSV has too many fields...

LOAD @1,

     @2,

     @3

FROM

testLoad.csv

(txt, codepage is 1252, no labels, delimiter is ';', msq, header is 1 lines);

So, how can I easily recognize this field renaming just this one?

Regards,

Erich

7 Replies
Not applicable

if it is a true CSV i.e. comma delimeted the delimeter is wrong : -

LOAD ,

     Field1,

     Field2

FROM

testLoad.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

giakoum
Partner - Master II
Partner - Master II

I would load the fields line first in QV like this :

First 1 LOAD @1 FROM

C:\Users\giakouma\Desktop\1.csv

(txt, codepage is 1252, no labels, delimiter is ',', msq);

Then I would loop through it trying to identify where the field name is missing, and form a new field list string to use in the normal load.

The load above works but the rest is only theory, have not tried it...

erichshiino
Partner - Master
Partner - Master
Author

You're right, it wasn't a CSV, but I correct the file and the script and the problem persist.

It fails even if it is a Load *

Thanks,

Erich

erichshiino
Partner - Master
Partner - Master
Author

Hi,

It would be possible to use  your first load and use it to generate field names in the following script:

I'd put @1 from your script in a variable and use subfield to segment it...

Then I could apply the names on the fields from the second part...

It's seem very complicated but it would work

LOAD @1,

     @2,

     @3

FROM

testLoad.csv

(txt, codepage is 1252, no labels, delimiter is ';', msq, header is 1 lines);

Hope there is still an easier solution

Regards,

Erich

Not applicable

try changing codepage is 1252 to UTF8

erichshiino
Partner - Master
Partner - Master
Author

Sorry, same errror...

erichshiino
Partner - Master
Partner - Master
Author

I tried to recognized the field name and solve it using this:

LOAD [] as x,

     Field1,

     Field2

FROM

testLoad.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Then, In a stranger source file, I tried to read two blank field names and this code also worked:

ABC:

LOAD [] as x,

     [] as y,

     Field2

FROM

testLoad.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Maybe the wizard should help us create this...

Regards,

Erich