read_csv

read_csv()

read_csv(path: str, separator: str | None = None, quote: str | None = None, has_header: bool = True, num_threads: typing.SupportsInt | None = None, error_mode: str | None = None, max_errors: typing.SupportsInt | None = None, encoding: str | None = None, comment: str | None = None, skip_empty_rows: bool = True, guess_integer: bool = True, trim_ws: bool = True, escape_backslash: bool = False, decimal_mark: str = ‘.’, skip: typing.SupportsInt = 0) -> vroom_csv._core.Table

Read a CSV file into a Table.

Parameters

Name Type Description Default
path str Path to the CSV file to read. required
separator str Field separator character. Default is auto-detect. required
quote str Quote character. Default is ‘“’. required
has_header bool Whether the file has a header row. Default is True. required
num_threads int Number of threads to use. Default is auto-detect. required
error_mode str Error handling mode: - “disabled” (default): No error collection, maximum performance - “fail_fast” or “strict”: Stop on first error - “permissive”: Collect all errors, stop on fatal - “best_effort”: Ignore errors, parse what’s possible required
max_errors int Maximum number of errors to collect. Default is 10000. Setting this automatically enables “permissive” mode if error_mode is not set. required
encoding str Force input encoding. Default is auto-detect. Supported: “utf-8”, “utf-16le”, “utf-16be”, “utf-32le”, “utf-32be”, “latin1”, “windows-1252”. required
comment str String that marks comment lines. Lines starting with this string are skipped during parsing. Supports multi-character prefixes like “//” or “##”. Default is None (no comment skipping). required
skip_empty_rows bool Whether to skip empty lines in the input. Default is True. required
guess_integer bool Whether to infer integer types (INT32/INT64) for integer-like values. Default is True. required
trim_ws bool Whether to trim leading and trailing whitespace from field values. Default is True. required
escape_backslash bool Whether to use backslash escaping (") instead of doubled quotes (““). When True, backslash sequences are interpreted: " -> quote, \\ -> backslash, \n -> newline, \t -> tab, \r -> carriage return. Default is False. required
decimal_mark str Decimal separator character (‘.’ or ‘,’). Default is ‘.’. required
skip int Number of lines to skip before the header row. Default is 0. required

Returns

Name Type Description
Table A Table object containing the parsed data.

Raises

Name Type Description
RuntimeError If parsing fails. In permissive mode, collected errors are included in the exception message.

Examples

>>> import vroom_csv
>>> table = vroom_csv.read_csv("data.csv")
>>> print(table.num_rows, table.num_columns)

With error handling

>>> table = vroom_csv.read_csv("data.csv", error_mode="permissive")

With encoding override

>>> table = vroom_csv.read_csv("data.csv", encoding="latin1")

With comment skipping

>>> table = vroom_csv.read_csv("data.csv", comment="#")