# Improved Cloud Access for Archival Formats (gzip and zip)

**URL:** <https://discourse.pangeo.io/t/improved-cloud-access-for-archival-formats-gzip-and-zip/3373>\
**Category:** Data\
**Created:** [April 17, 2023, 7:00pm UTC](https://discourse.pangeo.io/t/improved-cloud-access-for-archival-formats-gzip-and-zip/3373 "2023-04-17T19:00:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![forrestfwilliams](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/forrestfwilliams/32/1651_2.png) [@forrestfwilliams](https://discourse.pangeo.io/u/forrestfwilliams)\
**Post date:** [April 17, 2023, 7:00pm UTC](https://discourse.pangeo.io/t/improved-cloud-access-for-archival-formats-gzip-and-zip/3373/1 "2023-04-17T19:00:14Z")

</div>

Compression is a key way that we can increase download speeds and reduce data storage costs, but many compression types such as the popular DEFLATE compression used in gzip and zip files **do not support random access reads**. This isn’t a problem if you plan to download/decompress the whole data file, but cloud access patterns rely on the ability to grab only the data they need from much larger files (i.e., random access reads). Since _SO_ much data is stored in either gzip or zip archives, this severely limits our ability to efficient cloud access to older datasets.

I’ve been working on a new project that should make this much easier though! Mark Adler, the creator of the popular `zlib` compression library developed a utility called zran to provide pseudo-random reads for these formats via the creation of sidecar index files. These files contain information on the decompression state of the parent file at various points and can be used to start reading at roughly 20 KB block boundaries throughout the file.

I’ve taken Mark’s utility and wrapped it as a Python library so that others can use it more easily. You can install the zran python package via [PyPI](https://pypi.org/project/zran/), or check out a development version on [GitHub](https://github.com/forrestfwilliams/zran).

My hope is that we can combine this utility with other projects such as `kerchunk` and `fsspec` to provide Xarray-esque access to compressed file archives.

FYI, there is another package that does something similar called `indexed_gzip`, but it is tailored to a specific neuro-imaging use case and the developer doesn’t have much time to devote to the project.

---

<div class="post-metadata">

**Author:** ![TomAugspurger](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/tomaugspurger/32/21_2.png) [@TomAugspurger](https://discourse.pangeo.io/u/TomAugspurger)\
**Post date:** [April 17, 2023, 8:01pm UTC](https://discourse.pangeo.io/t/improved-cloud-access-for-archival-formats-gzip-and-zip/3373/2 "2023-04-17T20:01:59Z")

</div>

Thanks for sharing. I came across [GitHub - sozip/sozip-spec: Specification of seek-optimized zip file profile](https://github.com/sozip/sozip-spec) the other day, which sounds related (though I haven’t used it yet).

---

<div class="post-metadata">

**Author:** ![forrestfwilliams](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/forrestfwilliams/32/1651_2.png) [@forrestfwilliams](https://discourse.pangeo.io/u/forrestfwilliams)\
**Post date:** [April 17, 2023, 8:43pm UTC](https://discourse.pangeo.io/t/improved-cloud-access-for-archival-formats-gzip-and-zip/3373/3 "2023-04-17T20:43:03Z")

</div>

Oh nice I hadn’t come across this project before. From a quick read, it looks like `sozip` will create new zip files with these indexes. Conversely `zran` will create indexes for existing DEFLATE compressed data without rewriting it.
