Skip to content
KxSystemsPublic

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

csv

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)t:.csv.read `:trades.csv
q).tbl:use`kx.tbl
q).tbl.describe t                 / per-column statistics, from the tbl module

The module provides:

  • read loads a file into a table, or processes it in batches with the batchsize and postProcess options. 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:// or https:// 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 formats option gives the format of a column, such as %d-%b-%Y or %Y%m%d %H%M%S%f, for dates and times that the rules don't recognise.
  • infer returns the type the rules picked for each column, and why, so you can check it before loading.
  • peek returns the rows that infer samples, the first rows and blocks of rows from evenly spaced places, to look around in a file.
  • rejects lists 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. The strict option turns such values into an error, and the ragged option leaves the lines out or signals an error.
  • Loading a file in batches: the batchsize option loads a file that is too large for memory a batch at a time, and postProcess filters 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 tbl module.

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.

Testing

This repository includes GitHub Actions that test the module APIs. The tests:

  1. Test the module with vanilla KDB-X.
  2. Test the module with KDB-X and qmamba.

For more information, see the KX GitHub Actions.

API documentation

See the API reference.

Installation documentation

See the install guide.

Conda package

To build and host a conda package, including building and installing from a conda channel on your machine, see Conda usage.

Notice

Copyright (c) 2026 KX Systems, Inc.

Licensed under the Apache License, Version 2.0.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages