pyarrow.csv.write_csv#

pyarrow.csv.write_csv(data, output_file, write_options=None, MemoryPool memory_pool=None)#

Write record batch or table to a CSV file.

Parameters:
datapyarrow.RecordBatch or pyarrow.Table

The data to write.

output_filestr, path, pyarrow.NativeFile, or file-like object

The location where to write the CSV data.

write_optionspyarrow.csv.WriteOptions

Options to configure writing the CSV data.

memory_poolMemoryPool, optional

Pool for temporary allocations.

Examples

>>> import pyarrow as pa
>>> from pyarrow import csv
>>> legs = pa.array([2, 4, 5, 100])
>>> animals = pa.array(["Flamingo", "Horse", "Brittle stars", "Centipede"])
>>> entry_date = pa.array(["01/03/2022", "02/03/2022",
...                        "03/03/2022", "04/03/2022"])
>>> table = pa.table([animals, legs, entry_date],
...                  names=["animals", "n_legs", "entry"])
>>> csv.write_csv(table, "animals.csv")
>>> write_options = csv.WriteOptions(include_header=False)
>>> csv.write_csv(table, "animals.csv", write_options=write_options)
>>> write_options = csv.WriteOptions(delimiter=";")
>>> csv.write_csv(table, "animals.csv", write_options=write_options)