Replicating R unz function in Power Query. Based on http://sql10.blogspot.co.uk/2016/06/reading-zip-files-in-powerquery-m.html
✓ Published0🌍 Public
HHugoberry
Last edited Mar 20, 2017
Created on Mar 20, 2017
This example demonstrates how to read a specific file from a ZIP archive directly in Power Query using a custom M function. It shows the binary-parsing logic that replicates R’s `unz` utility by manually decoding the ZIP container format. The code defines binary readers via `BinaryFormat` components, including `UnsignedInteger32` and `UnsignedInteger16` for headers, and uses `Binary.Decompress` with `Compression.Deflate` to inflate the stored file data. A `BinaryFormat.List` iterator scans the archive for the `PKZIP` signature (`0x04034B50`) to locate and extract the requested file by name. The function returns the uncompressed binary content for the matching entry.
AI-generated description