Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
NenadV
Creator II
Creator II

How to create a fixed field txt file?

Hi, the standard "STORE table INTO file.txt (txt)" command stores fields separated by commas.

1. Is there a way to eliminate those commas?

2. Is there a way to get that file with fixed field lengths?

3. Is there a way not to store field labels?

For example:

Current:

Field_1,Field_2,Field_3,Field_4,Field_5
S1234,2,000010,000000,24082021

S123456789,2,000010,000000,24082021

Future:

Field_1,Field_2,Field_3,Field_4,Field_5
S1234     200001000000024082021

S123456789200001000000024082021

Thanks

 

1 Solution

Accepted Solutions
marcus_sommer

It's possible but you will need some additionally efforts like the concatenating of the fields by applying the wanted filling-method to get the fixed-length. Maybe something in this way:

t1: load F1 & repeat(18-len(F1), chr(32)) & F2 & repeat(18-len(F2), chr(32)) as [F1+F2] from X;

let fn = fieldvalue('F1+F2', 1);

t2: noconcatenate load * resident t1 where recno() > 1;

rename fields [F1+F2] to [$(fn)];

store t2 into t2.txt (txt);
drop tables t1, t2; let fn = null();

- Marcus

View solution in original post

6 Replies
tincholiver
Creator III
Creator III

Did you try STORE in Excels like : xlsx(txt)

stevejoyce
Specialist II
Specialist II

1 - can be done like this after your store:  (txt, delimiter is ' ');

2 - i don't know what you mean by this

3 - there is a nifty workaround: Save Qlikview table as csv without header (sstoichev.eu)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I don't think delimiter is honored in STORE?

marcus_sommer

It's possible but you will need some additionally efforts like the concatenating of the fields by applying the wanted filling-method to get the fixed-length. Maybe something in this way:

t1: load F1 & repeat(18-len(F1), chr(32)) & F2 & repeat(18-len(F2), chr(32)) as [F1+F2] from X;

let fn = fieldvalue('F1+F2', 1);

t2: noconcatenate load * resident t1 where recno() > 1;

rename fields [F1+F2] to [$(fn)];

store t2 into t2.txt (txt);
drop tables t1, t2; let fn = null();

- Marcus

stevejoyce
Specialist II
Specialist II

@rwunderlich I tested store [table] into table.txt (txt, delimiter is ' ') and does store as expected... with a space where you'd normally see comma.  At least in my version of QSE Feb 2021.

NenadV
Creator II
Creator II
Author

@marcus_sommer  Excellent Marcus. Thank you. The only change needed was to replace parameters in the repeat function to be like repeat(chr(32), 18-len(F1)), but that is just for future readers of this great and complete answer.

@stevejoyce Rob was right. I tested this and got the same result. Thanks @rwunderlich 

Gentlemen, all this is greatly appreciated. Take care