Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
qingkong
Contributor II
Contributor II

Load field fourth record

Respected elder

Here is my script loading TXT, I want to directly load the fourth row of data, and use delimiters to separate the columns.

lt22.jpg

1 Solution

Accepted Solutions
rubenmarin

Hi what I meant to say is to change "RecNo()=4" to "Recno()>=3", also to try to change the header.

At the end you need:

LOAD 
    "TO Number",
    Material,
    "Material Description",
    "Source Stor.Bin",
    SrceTgtQty,
    "Stor. bin",
    S,
    S as S2,
    Typ,
    "Dest. Bin",
    "Mvmt Type",
    "Mvmt Typ",
    User,
    "Created On",
    Conf.t.
FROM [lib://Escritorio/LT22.txt]
(txt, codepage is 28591, embedded labels, delimiter is '|', msq, header is 3 lines)
where ReCno()>=2;

So, 3 lines of header, the RecNo() >=2 to skipt the line with all dash.

And set the names of the fields because the file starts with an '|' that will create an empty blank field. And there are two columns called 'S' wich causes an error because there can't be repeated names for columns, so you need to rename one (in this case I renamed the 2nd to S2).

View solution in original post

6 Replies
rubenmarin

Hi, you can change the delimiter to '|', it wouldbe in the 3rd drop down of the top.

You can also change in script, there you can also set the condition to only load the 4th row:

(txt, codepage is 28591, embedded labels, delimiter is '|', msq)
Where RecNo()=4;

By the screenshot I think you also need to change the headers rwos to 1 instead of 0.

qingkong
Contributor II
Contributor II
Author

Dear 

Thank you for reply
I want to load the fields from the third line, not just the third line. Because I'm going to use the third line as the fields,The third row field is then split into columns.

LT22.PNG

rubenmarin

Hi, just change RecNo()=4 to Recno()>=3.

Or add more header lines if 3rd line is the field names.

qingkong
Contributor II
Contributor II
Author

I have tried it and it is wrong. I have uploaded the attachment

lt22.jpg

rubenmarin

Hi what I meant to say is to change "RecNo()=4" to "Recno()>=3", also to try to change the header.

At the end you need:

LOAD 
    "TO Number",
    Material,
    "Material Description",
    "Source Stor.Bin",
    SrceTgtQty,
    "Stor. bin",
    S,
    S as S2,
    Typ,
    "Dest. Bin",
    "Mvmt Type",
    "Mvmt Typ",
    User,
    "Created On",
    Conf.t.
FROM [lib://Escritorio/LT22.txt]
(txt, codepage is 28591, embedded labels, delimiter is '|', msq, header is 3 lines)
where ReCno()>=2;

So, 3 lines of header, the RecNo() >=2 to skipt the line with all dash.

And set the names of the fields because the file starts with an '|' that will create an empty blank field. And there are two columns called 'S' wich causes an error because there can't be repeated names for columns, so you need to rename one (in this case I renamed the 2nd to S2).

qingkong
Contributor II
Contributor II
Author

Very detailed reply. The problem has been solved. Thank you very much.