read_csv

xorq.read_csv(sources, table_name=None, **kwargs)

Lazily load a CSV or set of CSVs.

This function delegates to the read_csv method on the current default backend (DuckDB or xorq.config.default_backend).

Parameters

Name Type Description Default
sources str | Path | Sequence[str | Path] A filesystem path or URL or list of same. Supports CSV and TSV files. required
table_name str | None A name to refer to the table. If not provided, a name will be generated. None
kwargs Any Backend-specific keyword arguments for the file type. For the DuckDB backend used by default, please refer to: * CSV/TSV: https://duckdb.org/docs/data/csv/overview.html#parameters. {}

Returns

Name Type Description
ir.Table Table expression representing a file

Examples

>>> import xorq
>>> xorq.options.interactive = True
>>> lines = '''a,b
... 1,d
... 2,
... ,f
... '''
>>> with open("/tmp/lines.csv", mode="w") as f:
...     nbytes = f.write(lines)  # nbytes is unused
>>> t = xorq.read_csv("/tmp/lines.csv")
>>> t
┏━━━━━━━┳━━━━━━━━┓
┃ a      b      ┃
┡━━━━━━━╇━━━━━━━━┩
│ int64string │
├───────┼────────┤
│     1d      │
│     2NULL   │
│  NULLf      │
└───────┴────────┘