Read: Import record data from an iterable using a layout

class txf.Read(iterable[, source=None[, layout='csv'[, **config]]])

The Read transform pulls records from an iterable using a particular layout. The output field names will be determined from the input or the config parameters. Read is the logical inverse of Write.

iterable: iterable

The input. Each row will be generated from the result of next(iterable).

source: Transform or None

An optional input pipeline. New rows will be merged with the output of this pipeline.

layout: str

The layout to generate the output in. Supported read layouts are:

  • csv Comma-separated values. The header will be read to provide the field names.

  • json JavaScript Object Notation records in array layout ([{..},...])

  • jsonl JavaScript Object Notation Line layout ({...}\n{...}\n...)

  • md GitHub Markdown tables with headers

  • text Treats the file as a single field with a name taken from config['default_fieldnames'].

config: kwargs

Extra arguments to be passed to the layout object.

Usage

Read(p, sys.stdin 'csv')
Read(p, records, 'jsonl')