Write: Export records to a writable object using a layout¶
- class txf.Write(source, outfile[, layout='csv'[, **config]])¶
The
Writetransform 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.Writeis 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:
csvComma-Separated ValuesjsonJavaScript Object Notation (an array of objects)jsonlJavaScript Object Notation lines (one object per row)mdGitHub MarkdownpyPython dictsrstcsv 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')