csv's without column headings

1,074 views
Skip to first unread message

Nick

unread,
Feb 15, 2011, 7:08:12 AM2/15/11
to Kdb+ Personal Developers
Is it possible to load in csv files without column headings, and then
name the columns after you load the file in?

If not, is it possible to load in a csv file with 2 columns without
headings and then make a dictionary of the 2 columns?

Thanks,

Nick

Nick

unread,
Feb 15, 2011, 7:12:38 AM2/15/11
to Kdb+ Personal Developers
As always, as soon as you ask a question you realise the solution.

For the dictionary I could just do the bla:("IS";enlist ",") 0:`
$filename

Then
dict:(first each bla)! last each bla


I'm still unsure of how you could name the columns once they come in
if there are more than two columns.

Any ideas?

Thanks,

Nick

Simon Garland

unread,
Feb 15, 2011, 7:16:12 AM2/15/11
to personal...@googlegroups.com

Nick

unread,
Feb 15, 2011, 7:56:11 AM2/15/11
to Kdb+ Personal Developers
Thanks Simon,

Nick

On Feb 15, 12:16 pm, Simon Garland <si...@kx.com> wrote:
> https://code.kx.com/trac/wiki/Cookbook/UsingKdb#WhatiftheCSVfileconta...

Runk, Brian

unread,
Feb 15, 2011, 9:44:51 AM2/15/11
to personal...@googlegroups.com
[1253]$ cat > test.csv
abc,123
def,456

[1254]$ rlwrap q
...
q)`sym`num!("SI";",") 0: `:test.csv // don't enlist the delimiter if you don't have col headers
sym| abc def
num| 123 456

q)flip `sym`num!("SI";",") 0: `:test.csv // you can flip it into a table
sym num
-------
abc 123
def 456

q)("SI";enlist ",") 0: `:test.csv // if you enlist the delimiter q uses first row as headers
abc 123
-------
def 456

Thanks,

Nick

--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To post to this group, send email to personal...@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbpl...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.


--------------------------------------------------------------------------
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.

Reply all
Reply to author
Forward
0 new messages