Hello,
I have a table t1 in memory, that contains a list of strings like so :
c1 c2
==================================
(Station1) ((A1;9000);(B1;10000))
(Station3) ((A3;4000;A3;5000)(B5;10000))
…
How may I save this table to a csv? I’ve tried save `:t1.csv - I get 'type.
A “save `:t1.txt” yields a 'length.
I need it as ascii, so it may be read inside R/Python.
Thanks,
Kumar
q)update .Q.s1 each c2 from t1 q)save
:t1.txt
Pure awesomeness ! Thanks, Connor !
Kumar
P.S : A save `:t1.csv works perfectly as well, with commas in place.
Although the above method is quick, it’s limited by the console size on the q process - which can lead to strings being truncated
See http://code.kx.com/wiki/Reference/ConsoleSize
e.g.
q)tab:(txt:((1;sym);(2;
sym2);(3;`sym3)))
q)\c 5 5 /set console size
q)update .Q.s1 each txt from tab
txt
“(1;sym)" "(2;
sy..”
“(3;`sy..”
Might be safer to build the string yourself, Krishna!
q)update "|"sv’string c2 from tab /pipe delimit each element
Thanks,
Connor
Thanks very much for pointing that out, Connor. I’m going to have to build the string myself, I guess. You’re right. Let me look some more and get back.
Kumar