Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am attempting to load data from a text file where the delimiter is '|'
My load statement is
(txt, codepage is 1252, embedded labels, delimiter is '|', msq, no eof )
When the data is loaded though records are jumbled up so for instance you will see sales regions appearing under sales manager.
I have tried both standard and no quotes to no avail. Also checked specific lines using rowNo and a text editor but can't spot anything visible.
I believe this topic has been raised but no resolution was offered.
Thanks
Hi in answer to your questions :
Yes
Yes
Not sure how to verify
Does it get loaded fine in other applications like excel?
Yes seems to work ok in excel ( using a small extract of data ) but not csv or txt.
Sorry correction - no does not work in excel either
Sorry I did not get you
Just to clarify - It does not load fine in other applications ie excel
One method of dealing with troublesome textfiles is to load them as fixed record files without specifying field breaks. Each record will then contain a single field holding the entire row.
The next step is to use the SubField() function, using the | delimiter, in a resident load to split up the data in fields. Hopefully you'll be able to load most data this way. If you have isolated the problem you may be able to do some damage control here on the problem rows as well.
You will need to specify each field (field1, field2...) of course
RawData:
LOAD @1:n as raw
FROM [your_file]
(fix, codepage is 1252, no labels);
Data:
Load
SubField(raw, '|', 1) As field1,
SubField(raw, '|', 2) As field2,
...
Resident RawData;
You probably have a missing '|' field separator somewhere in your records.
I know it's very annoying to debug this kind of issues, but you can load whole line from the text file as one text field and calculate a number of '|' characters in each one of them.
The string(s) with anomaly (with the number of separators less than usual) should be pointed out easily.
Regards,
Vladimir
Hi So I checked this but the offending lines do in fact have the same number of separators
Also if I load the offending line on it's own with just the header row it loads fine. It's as if the structure of the file itself is what's causing the problem