-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: add CsvProcessor to python bindings
- Loading branch information
Showing
9 changed files
with
114 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
from pathlib import Path | ||
|
||
import feco3 | ||
import pyarrow as pa | ||
|
||
from . import common | ||
|
||
|
||
def test_pyarrow_batches(): | ||
path = common.get_case_path("slash_form.fec") | ||
fec = feco3.FecFile(path) | ||
batcher = feco3.PyarrowBatcher(fec) | ||
# Can convert to list | ||
batches = list(batcher) | ||
assert len(batches) > 1 | ||
seen_codes = set() | ||
for b in batches: | ||
assert isinstance(b, feco3.ItemizationBatch) | ||
assert isinstance(b.code, str) | ||
assert isinstance(b.records, pa.RecordBatch) | ||
assert b.records.num_rows > 0 | ||
assert b.records.num_columns > 0 | ||
seen_codes.add(b.code) | ||
|
||
assert seen_codes == {"SA11AI", "SD10", "SC2/10", "SC/10", "SB17"} | ||
|
||
# We have used up the fec file, so iterating again finds no itemizations | ||
assert list(feco3.PyarrowBatcher(fec)) == [] | ||
|
||
|
||
def test_csvs(tmp_path: Path): | ||
path = common.get_case_path("slash_form.fec") | ||
fec = feco3.FecFile(path) | ||
fec.to_csvs(tmp_path) | ||
assert len(list(tmp_path.glob("*.csv"))) == 5 | ||
|
||
|
||
def test_parquets(tmp_path: Path): | ||
path = common.get_case_path("slash_form.fec") | ||
fec = feco3.FecFile(path) | ||
fec.to_parquets(tmp_path) | ||
assert len(list(tmp_path.glob("*.parquet"))) == 5 |