MichaelGuest
How can I read a pipe delimited file into kdb?
source.txt:
name|id|age|height
P13141|212314|23|167
R3145|212315|34|190
For reading a pipe delimited file you can use 0:
Here I first use read0 to read the file as a list of strings, to demonstrate it’s the same format you gave:
q)read0 `:source.txt
"name|id|age|height"
"P13141|212314|23|167"
"R3145|212315|34|190"
On the right hand side of 0: We supply the file handle.
On the left is a two item list
“SJII” – denotes the four types for each column – symbol, long, int, int
enlist “|” – means take the pipe as the delimiter and enlist tells kdb there is a header row
like so:
q)("SJII"; enlist "|") 0: `:source.txt
name id age height
------------------------
P13141 212314 23 167
R3145 212315 34 190