Search code examples
pythonjupyter-notebookjupyterkdbpyq

Save KDB+/q table on a Mac


I'm new to q and I'm trying to save a file on my Mac. Currently using Jupyter Notebook if that makes a difference.

A quick table:

t:([] c1:`a`b`c; c2:1.1 2.2 3.3)

I first extract my current location by using \cd and i get: "/Users/Gorlomi/Documents/q"

but when I try

`:/Users/Gorlomi/Documents/q set t

I get:

evaluation error:

type

  [1]  (.q.set)


  [0]  `:/Users/Gorlomi/Documents/q set t
                                ^ 

I'm following examples from "Q for Mortals" from the kx website:

https://code.kx.com/q4m3/1_Q_Shock_and_Awe/#11-starting-q

For easy find use cmd (or ctrl) + F and find "t set t"

Thank you in advance.


Solution

  • There are two answers to this question, depending on whether you want to save your file as a flat table, or a splayed table.

    If you want to save you table as a flat table, you need to give a file name for your table. Currently, you're just giving it the directory that you want to save it in. So for instance, the following should work for you:

    `:/Users/Gorlomi/Documents/q/t set t
    

    If instead, you want to save your table as a splayed table, then you will need to pass it a directory (ideally, one that is not already being used by the file system). To do this, you will pass set a file path with a trailing forward slash. So the following should work for you:

    `:/Users/Gorlomi/Documents/q/t/ set t