save table as csv without headers - Kdb+ / qStudio

Home Forums Kdb+ / qStudio save table as csv without headers

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #165

    bigdata-dan
    Guest

    Hi,

    I normally use save `:table.csv to save my tables as csv files. If I wanted to save only the table data without the headers how could I do this? Should I use a shell script to cut the top line off?

    Thanks
    Dan

    #168

    admin
    Keymaster

    Hi Dan,

    An alternative method of saving a table is using 0:
    filehandle 0: “separator” 0: table

    For example:


    q)t
    sym time price size
    ------------------------------
    kjd 04:37:40.682 88.49717 28
    iik 07:54:24.777 66.8001 904
    oje 03:09:02.404 76.41439 511
    ndo 07:34:51.930 48.54351 139
    lkc 02:32:20.516 21.3479 775
    all 04:41:36.592 6.323408 353
    ..
    q)1_"," 0: t / convert to comma separated and drop first row
    "kjd,04:37:40.682,88.49717,28"
    "iik,07:54:24.777,66.8001,904"
    "oje,03:09:02.404,76.41439,511"
    "ndo,07:34:51.930,48.54351,139"
    "lkc,02:32:20.516,21.3479,775"
    "all,04:41:36.592,6.323408,353"
    "eln,02:16:35.865,75.98419,740"
    "bdi,10:33:07.085,6.746338,251"
    ..
    q)`:/temp/a.csv 0: 1_"," 0: t / save to file
    `:/temp/a.csv
    q)read0 `:/temp/a.csv / check what was written
    "kjd,04:37:40.682,88.49717,28"
    "iik,07:54:24.777,66.8001,904"
    "oje,03:09:02.404,76.41439,511"
    "ndo,07:34:51.930,48.54351,139"
    "lkc,02:32:20.516,21.3479,775"
    "all,04:41:36.592,6.323408,353"
    "eln,02:16:35.865,75.98419,740"
    "bdi,10:33:07.085,6.746338,251"
    ..

    #110175

    Cheryle
    Guest

    Woah! I’m really enjoying the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between usability
    and appearance. I must say you’ve done a superb job with this.
    Also, the blog loads very fast for me on Internet explorer.

    Exceptional Blog!

    cheap michael kors handbags

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.