Hi Vadim
You could use the attached script to save down data directly to directory. The first step you should perform in your q session is to load in
your raw data with the correct data types. We can use your data layout in the initial post as an example:
e.g. rawData: flip (date
timesym
price)!0:[(“DTSF”;“,”);<rawDataFileLocation>]
Then once the raw data has been loaded into q, this must be enumerated like below where the result is saved to a directory path:
e.g. loadedData: .Q.en[dirPath;rawData]
dirPath could be in the form `:hdb/testdata/ for example.
You can now load the attached script by performing the below command into your q session:
\l dataSave.q
This script will save the data down to directory but without having the partition (date) column listed within your table. The data will by sectioned by date when saved under the directory path. The savefunc function uses five parameters which you should input when running the function (one of these being the loadedData enumerated table above).
Some features are that the function can sort and apply attributes to the data within your table. The function will append data to the generated datapath directory in the correct format. If there is a problem with saving the data down, the error will be caught and displayed.
Once the script is loaded, you can run the function in the following format:
savefunc[loadedData;loadedDate;hdbdir;tableNamePath;sortCol]
e.g. to save down data for one particular date, run:
savefunc[loadedData;2014.04.01;`:hdb/testdata;`trade;`sym]
e.g. to save down data for all dates within your table, run:
savefunc[loadedData;;:hdb/testdata;
trade;sym] each exec distinct
date$date from loadedData
Expected output can be seen below
Saving data to directory :hdb/testdata/2014.04.01/trade/
Saving data to directory :hdb/testdata/2014.04.02/trade/
:hdb/testdata/2014.04.01/trade/
:hdb/testdata/2014.04.02/trade/
Hope this helps!
(Please see script attached)
Kind Regards
Natalie Inkpin
Financial Software Developer
AquaQAnalytics