代码:
store = zarr.ZipStore("/mnt/test.zip", "r")问题描述:嗨,麻烦你,我在ZipStorage:Alternatively, use a DirectoryStore when writing the data, then manually Zip the directory and use the Zip file for subsequent reads.的正式文档中找到了这个声明
我正在尝试将DirectoryStorage格式的Zarr数据集转换为ZipStorage。我使用Linux中提供的zip操作。zip -r test.zip test.zarr这里test.zarr是一个目录存储数据集,包括三个组。但是,当我尝试使用上面的代码打开它时,获得如下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/eddie/miniconda3/envs/train/lib/python3.8/site-packages/zarr/storage.py", line 1445, in __init__
self.zf = zipfile.ZipFile(path, mode=mode, compression=compression,
File "/home/eddie/miniconda3/envs/train/lib/python3.8/zipfile.py", line 1190, in __init__
_check_compression(compression)
File "/home/eddie/miniconda3/envs/train/lib/python3.8/zipfile.py", line 686, in _check_compression
raise NotImplementedError("That compression method is not supported")
NotImplementedError: That compression method is not supported我想知道我的压缩方法是否错了,以及是否有一些变通方法可以将目录存储转换为zip存储或其他DB格式,因为当组数增加时,以前的存储有那么多节点,传输也不太方便。提前谢谢。
Version and installation information
Value of zarr.__version__: 2.8.1
Value of numcodecs.__version__: 0.7.3
Version of Python interpreter: 3.8.0
Operating system (Linux/Windows/Mac): linux ubuntu 18.04
How Zarr was installed: pip发布于 2021-05-24 08:43:12
因为zarr已经使用压缩,所以在创建zip存档时不需要使用压缩。也就是说,您可以使用zip -r -0将文件存储在压缩存档中,而不需要压缩。
此外,您可能需要小心存储在zip存档中的路径。例如,如果我在某个目录"/path/ to /foo“中有一个zarr层次结构,并且希望将其存储到"/path/to/bar.zip”的zip文件中,我会这样做:
cd /path/to/foo
zip -r0 /path/to/bar.zip这确保了zip存档中存储的路径相对于原始根目录。
发布于 2021-05-24 16:05:25
在使用-r0选项进行压缩之后,您可以尝试使用store = zarr.ZipStore("/mnt/test.zip"),这样就不会再得到错误了。
https://stackoverflow.com/questions/67635491
复制相似问题