Skip to content
Browse documentation
Connect to data

Files and inline data

Read CSV, JSON, Parquet, and Excel files, or pass CSV, JSON, and text directly.

The examples below pass file paths or inline content to ava.source(). See Connect one source to set up AVA.

CSV

Inline CSV

Pass the CSV content as a string with type: 'csv'.

typescript
await ava.source({
  type: 'csv',
  options: { csv: 'city,revenue\nHangzhou,120\nShanghai,200\nBeijing,160' },
});
FieldTypeRequiredMeaning / default
csvstringYesRaw CSV content string
optionsCSVReadOptionsNoCSV reader options.

CSV files

Use type: 'csv-file' with a local path or HTTP(S) URL. For a protected URL, supply request headers in options.headers.

For remote CSV, JSON, Parquet, and Excel files, a nonempty headers object restricts redirects to the same origin (scheme, hostname, and effective port), with a limit of 20 redirects. This applies to both DuckDB and Python, including custom Python executors. Cross-origin redirects fail before the next request, even when the only header is Accept or the redirect upgrades HTTP to HTTPS. Downloads without headers, or with headers: {}, retain the underlying downloader's redirect behavior. Use the final trusted URL when a protected download requires a different origin.

typescript
await ava.source({
  type: 'csv-file',
  options: {
    path: 'https://example.com/sales.csv',
    headers: { Authorization: 'Bearer YOUR_TOKEN' },
    options: { header: true, delim: ';' },
  },
});
FieldTypeRequiredMeaning / default
pathstringYesLocal file path or http(s) URL
headersRecord<string, string>NoHTTP headers for remote sources (e.g. Authorization)
optionsCSVReadOptionsNoCSV reader options.

CSV reader options

Use these fields in options.options for csv and csv-file sources with DuckDB. Every field is optional. AVA forwards supplied values to read_csv; omitted values use DuckDB reader defaults or detection. Defaults below describe individual reader settings; automatic detection can determine the effective header, delimiter, and types.

FieldTypeRequiredMeaning / default
headerbooleanNoFirst line of each file contains the column names. Default false
namesstring[]NoColumn names, as a list
columnsRecord<string, string>NoColumn names → types struct, e.g. { col1: 'INTEGER' }. Disables schema auto-detection
typesstring[] | Record<string, string>NoColumn types, by position (list) or by name (struct)
all_varcharbooleanNoSkip type detection and read all columns as VARCHAR. Default false
normalize_namesbooleanNoRemove non-alphanumeric chars from column names; prefix reserved keywords with _
force_not_nullstring[]NoColumns that must not be matched against the NULL string
delimstringNoField delimiter (up to 4 bytes). Default ','
quotestringNoQuote character. Default '"'
escapestringNoEscape character for the quote within quoted values. Default '"'
commentstringNoCharacter used to initiate comments
new_linestringNoNew line character(s): '\r' | '\n' | '\r\n'
auto_detectbooleanNoAuto detect CSV parameters. Default true
auto_type_candidatesstring[]NoTypes the sniffer considers when detecting column types, e.g. ['BIGINT', 'DATE']
dateformatstringNoDate format used when parsing dates
timestampformatstringNoTimestamp format used when parsing timestamps
decimal_separatorstringNoDecimal separator for numbers. Default '.'
thousandsstringNoThousands separator (single char, different from decimal_separator)
nullstrstring | string[]NoString(s) that represent a NULL value
allow_quoted_nullsbooleanNoAllow the conversion of quoted values to NULL. Default true
sample_sizenumberNoNumber of sample lines for auto detection. Default 20480
buffer_sizenumberNoSize of the read buffers in bytes. Default 16 * max_line_size
files_to_sniffnumberNoFiles used by the sniffer for multi-file schema detection; -1 = all. Default 10
max_line_sizenumberNoMaximum line size in bytes. Default 2000000
parallelbooleanNoUse the parallel CSV reader. Default true
skipnumberNoNumber of lines to skip at the start of each file. Default 0
ignore_errorsbooleanNoIgnore any parsing errors encountered. Default false
null_paddingbooleanNoPad short rows with NULL values on the right. Default false
strict_modebooleanNoThrow an error upon encountering any issue. Default true
store_rejectsbooleanNoSkip faulty lines and store them in the rejects table. Default false
rejects_tablestringNoTemp table name for faulty lines. Default 'reject_errors'
rejects_scanstringNoTemp table name for faulty scans. Default 'reject_scans'
rejects_limitnumberNoUpper limit on faulty lines recorded per file; 0 = no limit. Default 0
encodingstringNoFile encoding: 'utf-8' | 'utf-16' | 'latin-1'. Default 'utf-8'
compressionstringNoCompression method: 'none' | 'gzip' | 'zstd'. Default auto (from file extension)
union_by_namebooleanNoAlign columns from different files by name instead of position. Default false
hive_partitioningbooleanNoInterpret the path as a Hive partitioned path. Default auto-detected
filenamebooleanNoAdd the source file path to each row as a filename column. Default false

JSON

Inline JSON

Pass an array of objects with type: 'json'.

typescript
await ava.source({
  type: 'json',
  options: { data: [{ city: 'Hangzhou', revenue: 120 }] },
});
FieldTypeRequiredMeaning / default
dataany[]YesArray of rows to load.
optionsJSONReadOptionsNoDuckDB reader parameters below.

JSON files

Use type: 'json-file' with a local path or HTTP(S) URL.

typescript
await ava.source({
  type: 'json-file',
  options: {
    path: './sales.json',
    options: { columns: { city: 'VARCHAR', revenue: 'DOUBLE' }, sample_size: -1 },
  },
});
FieldTypeRequiredMeaning / default
pathstringYesLocal file path or http(s) URL
headersRecord<string, string>NoHTTP headers for remote sources (e.g. Authorization)
optionsJSONReadOptionsNoDuckDB reader parameters below.

JSON reader options

Both JSON source types accept options.options when using the DuckDB engine. All fields are optional. The complete DuckDB JSON reader parameter list is exposed as JSONReadOptions:

ParameterTypeDefaultMeaning
auto_detectbooleantrueInfer schema
columnsRecord<string, string>UnsetNames → DuckDB types; selects columns
compression'auto_detect' | 'none' | 'gzip' | 'zstd''auto_detect'Codec
dateformatstring'iso'Date pattern
field_appearance_thresholdnumber0.1Sparse-object MAP threshold
filenamebooleanfalseInclude filename in SELECT *
format'auto' | 'unstructured' | 'newline_delimited' | 'array''auto'Input layout for read_json
hive_partitioningbooleanAuto-detectedPath partitions
ignore_errorsbooleanfalseSkip errors; NDJSON only
map_inference_thresholdnumber200STRUCT subfield limit; -1 disables MAP inference
maximum_depthnumber-1Inference depth; -1 unlimited
maximum_object_sizenumber16777216Bytes per object
maximum_sample_filesnumber32Files sampled
records'auto' | 'true' | 'false''auto'Unpack objects
sample_sizenumber20480Objects sampled; -1 scans all
timestampformatstring'iso'Timestamp pattern
union_by_namebooleanfalseMerge schemas

Inline data is serialized as an uncompressed JSON array; choose compatible reader options. Remote files are downloaded to temporary paths, so set compression explicitly for compressed URLs.

Parquet

Read a Parquet file from a local path or HTTP(S) URL.

typescript
await ava.source({
  type: 'parquet',
  options: { path: './sales.parquet' },
});
FieldTypeRequiredMeaning / default
pathstringYesLocal file path or http(s) URL
headersRecord<string, string>NoHTTP headers for remote sources (e.g. Authorization)

Excel

Read an .xlsx workbook from a local path or HTTP(S) URL. Each selected worksheet becomes a separate table named after the sheet. Call schema() to inspect the resulting tables and columns.

typescript
await ava.source({
  type: 'excel',
  options: {
    path: './sales.xlsx',
    sheets: [
      { sheet: 'Sales', range: 'A3:F100', header: true },
      { sheet: 'Costs', range: 'B2:C50', header: false },
    ],
  },
});

Source options

FieldTypeRequiredMeaning / default
pathstringYesLocal file path or HTTP(S) URL
headersRecord<string, string>NoHTTP headers for remote sources, such as Authorization
sheetsExcelSheetOptions[]NoSheets to load and their individual read settings; omitted loads all sheets with header: true

Sheet selection and reader options

Each entry in sheets contains a required sheet and optional ExcelReadOptions fields. Set these fields directly on the sheet entry, as shown above.

FieldTypeDefaultMeaning
sheetstringRequiredExact worksheet name; also used as the table name
rangestringInferred by the engineInclusive A1 rectangle, such as B3:F100
headerbooleantrueUse the first row of the selected range as column names; false keeps it as data
all_varcharbooleanfalseDuckDB only: read all cells as VARCHAR
ignore_errorsbooleanfalseDuckDB only: replace cells that fail type conversion with NULL
stop_at_emptybooleanfalse with range, otherwise trueDuckDB only: stop reading at the first empty row
empty_as_varcharbooleanfalseDuckDB only: infer empty cells as VARCHAR instead of DOUBLE

A supplied sheets list must be non-empty, and every name must exist in the workbook and appear only once. Ranges must be valid, bounded A1 rectangles. Invalid selections and unsupported fields are rejected.

Engine behavior

Both engines support sheet, range, and header. The Python engine rejects the four DuckDB-only options in the table above.

DuckDB reader options follow read_xlsx, except that AVA defaults header to true instead of inferring it. For example, to preserve mixed cell types as text and continue past empty rows:

typescript
await ava.source({
  type: 'excel',
  options: {
    path: './sales.xlsx',
    sheets: [{ sheet: 'Sales', all_varchar: true, stop_at_empty: false }],
  },
});

DuckDB rejects workbooks containing sheet names with literal XML entity text, such as Sales &amp; Tax, because its Excel extension can confuse them with another sheet. Rename those sheets or use the Python engine. Ordinary ampersands, quotes, and Unicode names are supported.

Text

Extract structured rows from unstructured text. This source calls your configured model.

typescript
await ava.source({
  type: 'text',
  options: { text: 'Hangzhou revenue was 120. Shanghai revenue was 200.' },
});
FieldTypeRequiredMeaning / default
textstringYesUnstructured text to extract using the configured model.