Skip to content

CSV

Read and write CSV files with a geometry column encoded as Well-Known Text.

geoarrow.rust.io.read_csv

read_csv(
    file: str | Path | BinaryIO,
    *,
    geometry_name: str | None = None,
    batch_size: int = 65536,
    coord_type: CoordType | CoordTypeT | None = None,
    has_header: bool = True,
    max_records: int | None = None,
    delimiter: str | None = None,
    escape: str | None = None,
    quote: str | None = None,
    terminator: str | None = None,
    comment: str | None = None
) -> Table

Read a CSV file from a path on disk into a Table.

Parameters:

  • file (str | Path | BinaryIO) –

    the path to the file or a Python file object in binary read mode.

Other Parameters:

  • geometry_name (str | None) –

    the name of the geometry column within the CSV.

  • batch_size (int) –

    the number of rows to include in each internal batch of the table.

  • coord_type (CoordType | CoordTypeT | None) –

    The coordinate type. Defaults to None.

  • has_header (bool) –

    Set whether the CSV file has a header. Defaults to True.

  • max_records (int | None) –

    The maximum number of records to read to infer schema. Defaults to None.

  • delimiter (str | None) –

    Set the CSV file's column delimiter as a byte character. Defaults to None.

  • escape (str | None) –

    Set the CSV escape character. Defaults to None.

  • quote (str | None) –

    Set the CSV quote character. Defaults to None.

  • terminator (str | None) –

    Set the line terminator. Defaults to None.

  • comment (str | None) –

    Set the comment character. Defaults to None.

Returns:

  • Table

    Table from CSV file.

geoarrow.rust.io.write_csv

write_csv(table: ArrowStreamExportable, file: str | Path | BinaryIO) -> None

Write a Table to a CSV file on disk.

Parameters:

  • table (ArrowStreamExportable) –

    the Arrow RecordBatch, Table, or RecordBatchReader to write.

  • file (str | Path | BinaryIO) –

    the path to the file or a Python file object in binary write mode.

Returns:

  • None

    None