Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
Did you try STORE in Excels like : xlsx(txt)
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)
I don't think delimiter is honored in STORE?
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
@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.
@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