pyarrow.csv.CSVWriter

class pyarrow.csv.CSVWriter(sink, Schema schema, WriteOptions write_options=None, *, MemoryPool memory_pool=None)

Bases: pyarrow.lib._CRecordBatchWriter

Writer to create a CSV file.

Parameters
  • sink (string, path, pyarrow.OutputStream or file-like object) – The location where to write the CSV data.

  • schema (pyarrow.Schema) – The schema of the data to be written.

  • write_options (pyarrow.csv.WriteOptions) – Options to configure writing the CSV data.

  • memory_pool (MemoryPool, optional) – Pool for temporary allocations.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(*args, **kwargs)

Initialize self.

close(self)

Close stream and write end-of-stream 0 marker.

write(self, table_or_batch)

Write RecordBatch or Table to stream.

write_batch(self, RecordBatch batch)

Write RecordBatch to stream.

write_table(self, Table table[, max_chunksize])

Write Table to stream in (contiguous) RecordBatch objects.

Attributes

stats

Current IPC write statistics.

close(self)

Close stream and write end-of-stream 0 marker.

stats

Current IPC write statistics.

write(self, table_or_batch)

Write RecordBatch or Table to stream.

Parameters

table_or_batch ({RecordBatch, Table}) –

write_batch(self, RecordBatch batch)

Write RecordBatch to stream.

Parameters

batch (RecordBatch) –

write_table(self, Table table, max_chunksize=None, **kwargs)

Write Table to stream in (contiguous) RecordBatch objects.

Parameters
  • table (Table) –

  • max_chunksize (int, default None) – Maximum size for RecordBatch chunks. Individual chunks may be smaller depending on the chunk layout of individual columns.