-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eac101
commit e35e12c
Showing
6 changed files
with
515 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
from typing import BinaryIO | ||
|
||
from arro3.core import Table | ||
from arro3.core.types import ArrowStreamExportable | ||
|
||
def read_csv( | ||
file: str | Path | BinaryIO, | ||
geometry_column_name: str, | ||
*, | ||
batch_size: int = 65536, | ||
) -> Table: | ||
""" | ||
Read a CSV file from a path on disk into a Table. | ||
Args: | ||
file: the path to the file or a Python file object in binary read mode. | ||
geometry_column_name: the name of the geometry column within the CSV. | ||
batch_size: the number of rows to include in each internal batch of the table. | ||
Returns: | ||
Table from CSV file. | ||
""" | ||
|
||
def write_csv(table: ArrowStreamExportable, file: str | Path | BinaryIO) -> None: | ||
""" | ||
Write a Table to a CSV file on disk. | ||
Args: | ||
table: the Arrow RecordBatch, Table, or RecordBatchReader to write. | ||
file: the path to the file or a Python file object in binary write mode. | ||
Returns: | ||
None | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from typing import BinaryIO, Union | ||
|
||
from arro3.core import Table | ||
from arro3.core.types import ArrowStreamExportable | ||
|
||
def read_geojson(file: Union[str, Path, BinaryIO], *, batch_size: int = 65536) -> Table: | ||
""" | ||
Read a GeoJSON file from a path on disk into an Arrow Table. | ||
Args: | ||
file: the path to the file or a Python file object in binary read mode. | ||
batch_size: the number of rows to include in each internal batch of the table. | ||
Returns: | ||
Table from GeoJSON file. | ||
""" | ||
|
||
def read_geojson_lines( | ||
file: Union[str, Path, BinaryIO], *, batch_size: int = 65536 | ||
) -> Table: | ||
""" | ||
Read a newline-delimited GeoJSON file from a path on disk into an Arrow Table. | ||
This expects a GeoJSON Feature on each line of a text file, with a newline character separating | ||
each Feature. | ||
Args: | ||
file: the path to the file or a Python file object in binary read mode. | ||
batch_size: the number of rows to include in each internal batch of the table. | ||
Returns: | ||
Table from GeoJSON file. | ||
""" | ||
|
||
def write_geojson( | ||
table: ArrowStreamExportable, file: Union[str, Path, BinaryIO] | ||
) -> None: | ||
""" | ||
Write to a GeoJSON file on disk. | ||
Note that the GeoJSON specification mandates coordinates to be in the WGS84 (EPSG:4326) | ||
coordinate system, but this function will not automatically reproject into WGS84 for you. | ||
Args: | ||
table: the Arrow RecordBatch, Table, or RecordBatchReader to write. | ||
file: the path to the file or a Python file object in binary write mode. | ||
Returns: | ||
None | ||
""" | ||
|
||
def write_geojson_lines( | ||
table: ArrowStreamExportable, file: Union[str, Path, BinaryIO] | ||
) -> None: | ||
""" | ||
Write to a newline-delimited GeoJSON file on disk. | ||
Note that the GeoJSON specification mandates coordinates to be in the WGS84 (EPSG:4326) | ||
coordinate system, but this function will not automatically reproject into WGS84 for you. | ||
Args: | ||
table: the Arrow RecordBatch, Table, or RecordBatchReader to write. | ||
file: the path to the file or a Python file object in binary write mode. | ||
Returns: | ||
None | ||
""" |
Oops, something went wrong.