Home

KDB+ q tips and tricks that I have used

Reading CSV File Data using KDB+ q

Reading a CSV file in KDB+ q is straightforward. Here’s a sample syntax:

data: ("SSSS"; enlist ",") 0 `:sample.csv

In this example:

  • sample.csv is the name of the CSV file.
  • S represents the symbol data type, and I is for integer data type.

Trick:

If all columns are of the same type, you can simplify the syntax. For instance, if you have more than 100 columns of type S, instead of specifying S repeatedly, you can use:

data: (100#"S"; enlist ",") 0 `:sample.csv

This approach avoids the need to repeatedly type the data type for each column.


Posted

in

by