mixle.data.sources.text_source module

Text connectors – CSV / JSON / JSONL (NDJSON) into a DataSource.

Pure standard library: usable in the base install with no extra. A Schema turns the raw strings into the Python types encoders expect (CSV columns are all strings until coerced).

read_csv(path, columns=None, *, structure=EXCHANGEABLE, schema=None)[source]

Read a CSV file (header row required) into a lazy DataSource of scalar/tuple records.

Parameters:
  • path (str)

  • columns (list[str] | None)

  • structure (SampleStructure)

  • schema (Schema | None)

Return type:

LazySource

read_jsonl(path, columns=None, *, structure=EXCHANGEABLE, schema=None)[source]

Read NDJSON / JSONL (one JSON object per line) into a lazy DataSource of dict/tuple records.

Parameters:
  • path (str)

  • columns (list[str] | None)

  • structure (SampleStructure)

  • schema (Schema | None)

Return type:

LazySource

read_json(path, columns=None, *, structure=EXCHANGEABLE, schema=None)[source]

Read a JSON file holding an array of record objects into a lazy DataSource.

Parameters:
  • path (str)

  • columns (list[str] | None)

  • structure (SampleStructure)

  • schema (Schema | None)

Return type:

LazySource