A KDB-X module that processes delimited files: it loads them into tables in memory, or works through them in batches to filter rows, persist them to disk or send them to a kdb+ tickerplant or a database service. You don't have to write a type string for 0:: the module infers the type of each column from a sample of rows.
q).csv:use`kx.csv
q)meta .csv.read "basic.csv"
c | t f a
------| -----
id | j
price | f
qty | j
sym | s
name | C
date | d
time | t
ts | p
flag | b
active| b
note | C
uid | g
empty | c
ymd | jThe module provides:
readloads a file into a table, or processes it in batches with thebatchsizeandpostProcessoptions. Optional arguments set the delimiter and options such as the rows to load, the columns to keep, lines to skip such as titles, totals and comments, and type overrides.- Several files: a pattern as the file name, with the wildcards of
like, loads the matching files as one table, with the types inferred once from all of them. - Files from a URL: an
http://orhttps://string is downloaded and loaded like a file, with redirects followed and errors for a status other than 200. - Compressed files: gzip files, also at a URL, are unzipped as they are read.
- Date and time formats: the
formatsoption gives the format of a column, such as%d-%b-%Yor%Y%m%d %H%M%S%f, for dates and times that the rules don't recognise. inferreturns the type the rules picked for each column, and why, so you can check it before loading.peekreturns the rows thatinfersamples, the first rows and blocks of rows from evenly spaced places, to look around in a file.rejectslists the values that don't parse as the type of their column, which a type guessed from a sample can get wrong, and the lines with the wrong number of fields. Thestrictoption turns such values into an error, and theraggedoption leaves the lines out or signals an error.- Loading a file in batches: the
batchsizeoption loads a file that is too large for memory a batch at a time, andpostProcessfilters or saves each batch. The types are inferred once, and all conversions apply. - Per-column statistics of the loaded table, and rows from evenly spaced places, are in the
tblmodule.
The type rules are grouped into sets. The basic rules always run, and the rules option adds the extended set (guesses from plain digits such as 20240115) and the financial set (bond prices and checked instrument identifiers such as ISIN and CUSIP). The module also reads formats such as thousands separators, ISO 8601 timestamps with a time zone and 12-hour times. See Type rules. A new domain is added as its own rule set without touching the others: see Adding a rule set.
The basic and extended rules come from csvutil.q, KX's long-standing CSV loading utility. Migrating from csvutil.q maps the old functions to the new ones.
This repository includes GitHub Actions that test the module APIs. The tests:
- Test the module with vanilla KDB-X.
- Test the module with KDB-X and qmamba.
For more information, see the KX GitHub Actions.
See the API reference.
See the install guide.
To build and host a conda package, including building and installing from a conda channel on your machine, see Conda usage.
Copyright (c) 2026 KX Systems, Inc.
Licensed under the Apache License, Version 2.0.
