Reading a CSV file in KDB+ q is straightforward. Here’s a sample syntax:
data: ("SSSS"; enlist ",") 0 `:sample.csv
In this example:
sample.csvis the name of the CSV file.Srepresents the symbol data type, andIis 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.