Multiframe-ZSTD-Datei: Wie erhalte ich Metadaten für jeden Frame?Python

Python-Programme
Anonymous
 Multiframe-ZSTD-Datei: Wie erhalte ich Metadaten für jeden Frame?

Post by Anonymous »

Ich möchte mehrere ndjson-Dateien mit der Python-Bindung python-zstandard in eine ZSTD-Datei komprimieren. Für die spätere Zufallssuche möchte ich, dass jede Datei unabhängig als Frame komprimiert wird. Zu diesem Zweck verwende ich

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)
Der CMD zstd -l "E:\Personal Projects\tmp\dataset.zst" gibt

Code: Select all

Frames  Skips  Compressed  Uncompressed  Ratio  Check  Filename
3      0     335 MiB                        None  E:\Personal Projects\tmp\dataset.zst
Wie kann ich die Metadaten (die komprimierte/unkomprimierte Größe und den Namen eines Frames) von dataset.zst erhalten?
Vielen Dank für Ihre Ausarbeitung.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post