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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
mauvasco62
Contributor III
Contributor III

Store into a fixed-width TXT

Hi everyone,

I neede you support

I would like to export a fixed-width TXT file from Qlik Sense using the STORE statement.

I have already created a field called RIGA_TXT containing the complete fixed-width record (59 characters), so my export table contains only one field:

EXPORT_TXT:
NoConcatenate
LOAD
    RIGA_TXT
RESIDENT CONTROLLO_PRESENZE
WHERE CTRL_STATO_IMPORT = 'VALIDO';

STORE EXPORT_TXT
INTO [lib://Output/PRESENZE_GESTIONALE.txt]
(txt);

The generated file is correct except for the first line, where Qlik writes the field name:

RIGA_TXT
0000000000000000000ORD0000800002026080300012712500000000000
0000000000000000000ORD0000800002026080400012712500000000000
...

What I need is:

0000000000000000000ORD0000800002026080300012712500000000000
0000000000000000000ORD0000800002026080400012712500000000000
...

So: one record per line, no header, no delimiter and no quotes.

I already tried:

(txt, no labels)

but no labels is not accepted in the STORE statement in my Qlik Sense environment.

Is there a native Qlik Sense solution to export a TXT file using STORE without writing the field name/header?

I would prefer to solve this directly in the Qlik load script, without using PowerShell or an external post-processing script.

Thanks in advance!

Mauro

Labels (1)
1 Reply
marcus_sommer
MVP
MVP

You could go with an approach like:

let FieldName = peek('RIGA_TXT', 0, 'CONTROLLO_PRESENZE');

EXPORT_TXT: NoConcatenate LOAD RIGA_TXT as X RESIDENT CONTROLLO_PRESENZE WHERE recno() > 0;

rename field X to FieldName; STORE EXPORT_TXT INTO [lib://Output/PRESENZE_GESTIONALE.txt] (txt);

Be aware that your previous condition of: CTRL_STATO_IMPORT = 'VALIDO' is not mandatory suitable for the peek() extract which takes exactly the defined record without considering any condition. Therefor it would be likely that you need another pre-load which extracts the wanted records and on this relates the peek() and the final load.