Code: Select all
import zstandard as zstd
from pathlib import Path
import shutil
file_to_compress = [r"E:\Personal Projects\tmp\chunk_0.ndjson",
r"E:\Personal Projects\tmp\chunk_0.ndjson"]
file_to_compress = [Path(p) for p in file_to_compress]
output_file = r"E:\Personal Projects\tmp\dataset.zst"
output_file = Path(output_file)
cctx = zstd.ZstdCompressor(write_content_size=True,threads=5)
with open(output_file, "wb") as f_out, cctx.stream_writer(f_out) as zst_writer:
for src in file_to_compress:
with open(src, "rb") as fin:
shutil.copyfileobj(fin, zst_writer)
zst_writer.flush(zstd.FLUSH_FRAME)
Code: Select all
Frames Skips Compressed Uncompressed Ratio Check Filename
3 0 335 MiB None E:\Personal Projects\tmp\dataset.zst
Vielen Dank für Ihre Ausarbeitung.
Mobile version