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

Function test_write_null_string

python/pyarrow/tests/test_csv.py:2159–2174  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2157
2158
2159def test_write_null_string():
2160 t = pa.Table.from_arrays([[1, 2, None], ["a", None, "c"]], ["c1", "c2"])
2161 buf = io.BytesIO()
2162 for write_options, res in [
2163 (WriteOptions(), b'"c1","c2"\n1,"a"\n2,\n,"c"\n'),
2164 (WriteOptions(null_string=''), b'"c1","c2"\n1,"a"\n2,\n,"c"\n'),
2165 (WriteOptions(null_string='NA'),
2166 b'"c1","c2"\n1,"a"\n2,NA\nNA,"c"\n'),
2167 (WriteOptions(null_string='N/A'),
2168 b'"c1","c2"\n1,"a"\n2,N/A\nN/A,"c"\n'),
2169 ]:
2170 with CSVWriter(buf, t.schema, write_options=write_options) as writer:
2171 writer.write_table(t)
2172 assert buf.getvalue() == res
2173 buf.seek(0)
2174 buf.truncate()
2175
2176
2177def test_read_csv_reference_cycle():

Callers

nothing calls this directly

Calls 3

WriteOptionsClass · 0.90
seekMethod · 0.80
write_tableMethod · 0.45

Tested by

no test coverage detected