Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to import a flat file with many instances

Hi,

I'm trying to import a metadata file for invoice creation.

There are two versions, one with only one invoice, and another with n invoices.

They both have in common that I have to transform them, and rotate them right to get the Fieldname / Data.

Layout Example without transform:

0HCDLNRE DE

0HCTTXDE Deutschland

0HCTTXRE Deutschland

0HDACUA1 asdf

0HDACUA3 gerg

0HDACUA4 Fsdf

Importing the files with only one invoice is quiet easy, but I am not able to import the files with many invoices.

Each new invoice begins with the following header:

BEGINOIS1990H

*TIME 20170818082841

*LANGUAGE DE

*ZZCONO 0

*ZZDIVI   

*ZZFACI 100

*ZZWHLO 100

*LAYOUT A4 

I would have to tell Qlikview to create a line feed before the next instance of "BEGINOIS1990H" begins I guess.


Does anyone have an idea on how to solve this task?

For testing I attached an example with a header and 2 invoiceheaders

Thanks in advance

12 Replies
sasiparupudi1
Master III
Master III

May be  You can do something like below

RawData:

LOAD @1,

     @2

FROM

[\\lnn63f1\u_t1487402003\sasidp\My Documents\Qlikview\TST Invoice.txt]

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

// exit script;

set vtable='T1';

For i=0 to NoOfRows('RawData')

LET vField1= FieldValue('@1',$(i));

If '$(vField1)'='BEGINInvoice' THEN

For j=1 to 5

LET vField$(j)= FieldValue('@1',$(i)+$(j));

LET vData$(j)= FieldValue('@2',$(i)+$(j));

    Next j

    $(vtable):

    LOAD

     '$(vData1)' AS '$(vField1)',

     '$(vData2)' AS '$(vField2)',

     '$(vData3)' AS '$(vField3)',

     '$(vData4)' AS '$(vField4)',

     '$(vData5)' AS '$(vField5)'

   AutoGenerate 1;

END IF;

Next i;

Drop Table RawData;

Anonymous
Not applicable
Author

Works perfectly fine.

And with the restricted selection its performing well.

Thanks a lot!

MarcoWedel

Glad it helped.

Please mark a reply correct, that actually answered your question:

Qlik Community Tip: Marking Replies as Correct or Helpful

thanks

regards

Marco