Back to Saving Tables

In Memory Tables · Saving Tables · Practice Question

Save a Table to a Custom CSV File Without Headers

Sign in to track your progress

Question

Given a table t, save it as a CSV file with a different filename than the variable name, and without the column headers in the file.

For example:

t:([] sym:`AAPL`MSFT`GOOG; price:185.25 410.1 142.8)

Solution

`:t_new.csv 0: 1 _ csv 0: t

Explanation

save only works when the output filename matches the variable name and always writes headers — neither of which holds here, so the lower-level 0: (write to file) is needed instead.

csv 0: t

renders t as CSV text — a list of strings, one per line, with the header on top.

1 _ then drops the first line of that list — the header — using _ (drop), since csv 0: t returns the header as the first item.

Finally, `:t_new.csv 0: writes the remaining lines (data only, no header) out to the chosen path — which is free to be any filename, since 0: doesn't require it to match the variable name the way save does.