The data I have is a kind of streaming data. And I want to store them into a single Parquet file. But Pyarrow will overwrite the Parquet file everytime. So How should I do?
I try not to close the writer but it seems impossible since If I didn't close it, then I could not read this file.
Here is the package:
import pyarrow.parquet as pp
import pyarrow as pa
for name in ['LEE','LSY','asd','wer']:
writer=pq.ParquetWriter('d:/test.parquet', table.schema)
arrays=[pa.array([name]),pa.array([2])]
field=[pa.field('name',pa.string()),pa.field('age',pa.int64())]
table=pa.Table.from_arrays(arrays,schema=pa.schema(field))
writer.write_table(table)
writer.close()
But actually I want to close the writer everytime, and reopen it to append one line to the data which like this:
for name in ['LEE','LSY','asd','wer']:
writer=pq.ParquetWriter('d:/test.parquet', table.schema)
arrays=[pa.array([name]),pa.array([2])]
field=[pa.field('name',pa.string()),pa.field('age',pa.int64())]
table=pa.Table.from_arrays(arrays,schema=pa.schema(field))
writer.write_table(table)
writer.close()