GlareDB

CSV Extension

The csv extension enables direct querying of CSV files. It is included by default in the CLI, Python, and WebAssembly (Wasm) bindings.

Functions

read_csv

Alias: scan_csv

The read_csv function takes a path to a CSV file and returns a table containing the parsed data.

SELECT * FROM read_csv('../testdata/csv/userdata1.csv');

By default, read_csv will:

  • Automatically infer column data types
  • Detect and skip the header row (if present)

You can inspect the inferred column names and types using the DESCRIBE statement:

DESCRIBE read_csv('../testdata/csv/userdata1.csv');

This returns a table with the name and data type of each column:

column_namedatatype
registration_dttmUtf8
idInt64
first_nameUtf8
last_nameUtf8
emailUtf8
genderUtf8
ip_addressUtf8
ccUtf8
countryUtf8
birthdateUtf8
salaryUtf8
titleUtf8
commentsUtf8

Direct URI Querying

CSV files can also be queried directly by using the file path or URI in the FROM clause:

SELECT * FROM '../testdata/csv/userdata1.csv';

Note: Support for custom parsing options, including explicit type definitions and header row overrides, will be available soon.