Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Today a gzip file is not recognised at all: it is not a zip, so TabularFile.Open hands it to the csv cursor, which refuses it as binary. .csv.gz is a common shape for exports and data deliveries, and the base class library decodes it (GZipStream), so it costs no dependency.
gzip is a compression wrapper around one file, not an archive. The natural model: decompress, then detect the inner file exactly as TabularFile.Open does today, and read it with its own cursor.
Shape
- Detected by bytes, like everything else:
1F 8B 08(gzip magic + deflate). Never by the.gzextension. - Inner csv: streamed through
GZipStream, dialect detected from the decompressed head — the same pathArchiveCursoralready uses for a csv entry (no seek on the inner stream). Moving back to the sheet means decompressing again from the start. - Inner xlsx / ods: needs random access, so copied into a
ChunkedBufferunder a bound, asArchiveCursordoes for a workbook entry. - Inner zip (
.zip.gz): probably out of scope, or read as an archive through the same buffer — decide. TabularFormat: a new member, or report the inner format with the gzip layer recorded elsewhere (e.g. onSheetProfile) — decide. The sheet'sSourcecould be the original file name from the gzip header (FNAME) when present.
Traps
- Bounds. A gzip bomb expands ~1000:1. The
ISIZEtrailer is the size mod 2³² and sits at the end of the file, so it cannot be trusted or read up front; bound the decompressed bytes while reading (MaxUncompressedBytes-like option) and fail with aTabularFormatExceptionwhen exceeded. - Multi-member gzip (concatenated members, e.g. from
cat a.gz b.gz):GZipStreamon .NET reads all members — pin it with a test. - Truncated / corrupt stream →
InvalidDataExceptionmapped toTabularFormatException, never leaked. -
Detect,Open, docs, README format list, error catalog.
How to verify
Fixtures gzipped with gzip and with .NET's GZipStream (different headers), a multi-member file, a truncated file, a bomb against the bound. Benchmark the 5M-row csv gzipped against the plain csv: the cost should be the decompression and nothing more, peak memory flat for a csv.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat: read gzip-compressed files as the file inside them (#80)