kdb+

Trying to loading a csv file into a q table via remote connection and keep getting - '/


I am using the example here to load a csv file...

https://code.kx.com/q/learn/tour/csvs/

But changed it slightly as I need to do this via a remote connection.

I know the file is where it needs to be...where con is the remote connection

q)con "\\cat /temp/example-mount/example.csv"
"id,price,qty"
"kikb,36.05,90"
"hlfe,96.57,84"
"mcej,91.34,63"
"iemn,57.12,93"
"femn,63.64,54"
"engn,94.56,38"
"edhp,63.31,97"
"ggna,72.39,88"
"mjlg,12.04,58"
..

But when I try to load the file...

q)con "t:(\"SFI\";enlist\",\") 0: `:/temp/example-mount/example.csv"
'/
  [0]  con "t:(\"SFI\";enlist\",\") 0: `:/temp/example-mount/example.csv"
       ^

Anyone know what might be wrong with the syntax? I'm guessing it has to do with escaping but I can't get it to work after changing it from the link. I tried via pykx with similar results.


Solution

  • You cannot create a symbol containing special characters such as - without creating as a string with "" and then casting to symbol `$

    q)`:/temp/example-mount/example.csv
    '/
      [0]  `:/temp/example-mount/example.csv
                                ^
    q)`$":/temp/example-mount/example.csv"
    `:/temp/example-mount/example.csv
    

    Try

    con "t:(\"SFI\";enlist\",\") 0: `$\":/temp/example-mount/example.csv\""
    

    https://code.kx.com/q/basics/datatypes/#symbols