2

I have a BIG csv file and would like to load this data into my KDB table. The csv can be separated by comma (,) but I would like to avoid splitting values if comma is in double quotes.

Say if I have "CUSTOMER 1, CUST1" - This value should not split into 2 values, because the comma is inside double quotes.

I'm trying to spend some time googling around, but it didn't help much. I know it's fairly simple query but I'm newbie, any one there to guide me please?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Shashi
  • 199
  • 1
  • 6
  • 19
  • Thanks for the response Mike. I did see that, but it didn't say if it *avoids* splitting the values if the separator is #inside# the quote. – Shashi Feb 19 '14 at 07:08
  • if you try the link Mike points out you'll find it does ignore commas inside double quotes – Manish Patel Feb 20 '14 at 07:21

1 Answers1

1

q should be smart enough to ignore what's between the quotation marks.

My CSV is as follows:

c1,c2
test,1
"CUSTOMER 1, CUST1",2
test,3

Once loaded, c1 is not split:

q)("*S";enlist ",") 0: `:tmp.csv
c1                  c2
----------------------
"test"              1
"CUSTOMER 1, CUST1" 2
"test"              3
user1895961
  • 1,176
  • 9
  • 22