MCPcopy Create free account
hub / github.com/apache/arrow / test_csv_format_compressed

Function test_csv_format_compressed

python/pyarrow/tests/test_dataset.py:3507–3524  ·  view source on GitHub ↗
(tempdir, compression, dataset_reader)

Source from the content-addressed store, hash-verified

3505 "zstd",
3506])
3507def test_csv_format_compressed(tempdir, compression, dataset_reader):
3508 if not pyarrow.Codec.is_available(compression):
3509 pytest.skip(f"{compression} support is not built")
3510 table = pa.table({'a': pa.array([1, 2, 3], type="int64"),
3511 'b': pa.array([.1, .2, .3], type="float64")})
3512 filesystem = fs.LocalFileSystem()
3513 suffix = compression if compression != 'gzip' else 'gz'
3514 path = str(tempdir / f'test.csv.{suffix}')
3515 with filesystem.open_output_stream(path, compression=compression) as sink:
3516 # https://github.com/pandas-dev/pandas/issues/23854
3517 # With CI version of Pandas (anything < 1.2), Pandas tries to write
3518 # str to the sink
3519 csv_str = table.to_pandas().to_csv(index=False)
3520 sink.write(csv_str.encode('utf-8'))
3521
3522 dataset = ds.dataset(path, format=ds.CsvFileFormat())
3523 result = dataset_reader.to_table(dataset)
3524 assert result.equals(table)
3525
3526
3527def test_csv_format_options(tempdir, dataset_reader):

Callers

nothing calls this directly

Calls 8

LocalFileSystemMethod · 0.80
CsvFileFormatMethod · 0.80
equalsMethod · 0.80
arrayMethod · 0.45
open_output_streamMethod · 0.45
writeMethod · 0.45
encodeMethod · 0.45
to_tableMethod · 0.45

Tested by

no test coverage detected