Is there anyway to directly insert rows into existing csv file - possibly similar to inserting into flat file?
X-Gm-Message-State: ALoCoQm29UfAxE7yoDGf0y7rY16SE0PZ79VCi14CNOmPrOTVUTLxPP9pdvHpL3Xlo0VaOaR1YjY0
Hi Drew,
Appending using a file handle works, I advise testing memory usage and
running on larger files.
// Write to file for first time
q)t:( a:1 2 3; b:pp
ooii) q)save
t.csv
`:t.csv
// check contents
q)(“**”;“,”)0:`t.csv
,“a” ,“1” ,“2” ,“3”
,“b” “pp” “oo” “ii”
// append using file handle
q)h:hopen `:t.csv
q)neg[h] each ","0:value flip t
-164 -164 -164i
// check contents
q)(“**”;“,”)0:`t.csv
,“a” ,“1” ,“2” ,“3” ,“1” ,“2” ,“3”
,“b” “pp” “oo” “ii” “pp” “oo” “ii”
Regards,
Ryan Hamilton
–
TimeStored.com - KDB+ Training, Consulting, Software
Ah excellent, cheers Ryan!
On Tuesday, 28 May 2013 11:29:08 UTC+1, Drew wrote:
Is there anyway to directly insert rows into existing csv file - possibly similar to inserting into flat file?
line-by-line is slow, do whole blocks instead
q)neg[h]","0:value flip t
Cheers,
?? Attila