Write: Export records to a writable object using a layout¶
- class txf.Write(source, outfile[, layout='csv'[, **config]])¶
The
Write
transform writes records to a stream using a specified layout. It has no impact on the stream except to write the records as they come in.Write
is the logical inverse ofRead
.- outfile: writable¶
The stream where the data will be sent.
- layout: writable¶
The layout to use for the output.
Supported write layouts are:
csv
Comma-Separated Valuesjson
JavaScript Object Notation (an array of objects)jsonl
JavaScript Object Notation lines (one object per row)md
GitHub Markdownpy
Python dictsrst
csv escaped for reStructured text
- config: kwargs¶
Extra arguments to be passed to the layout object.
Usage¶
Write(p, sys.stdout)
Write(p, open("log.json", "w"), 'jsonl')