简体   繁体   English

错误:在使用 cdb 文件时,解包需要 8 个字节的缓冲区

[英]error: unpack requires a buffer of 8 bytes in working with cdb file

I'm using python and pure-cdb library I have a large dataset with cdb extension which it's content is binary images and I want to read it.我正在使用 python 和 pure-cdb 库我有一个带有 cdb 扩展名的大型数据集,它的内容是二进制图像,我想阅读它。 Because this data set is large, I'm using chunking method, but when I set the chunk value to 1024, I get error CDB too small , and when I increase its value to 2048, I get struct.error: unpack requires a buffer of 8 bytes .what is the problem?因为这个数据集很大,所以我用的是分块的方法,但是当我把块值设置为 1024 时,我得到错误 CDB too small ,当我将它的值增加到 2048 时,我得到struct.error: unpack requires a buffer 8个字节。有什么问题? here is my code:这是我的代码:

import cdblib
with open('a.cdb', 'rb') as file:
    while chunk := file.read(2048):
        reader = cdblib.Reader(chunk)
        for key, value in reader.iteritems():
          print(key, value)
          print('+{},{}:{}->{}'.format(len(key), len(value), key, value))

thank you for your help谢谢您的帮助

Not a direct answer to your question, but instead an alternative solution: https://github.com/gstrauss/mcdb/ has no such limitations and has a python module.不是直接回答您的问题,而是替代解决方案: https://github.com/gstrauss/mcdb/没有此类限制,并且具有 python 模块。 https://github.com/gstrauss/mcdb/blob/master/contrib/python-mcdb/README https://github.com/gstrauss/mcdb/blob/master/contrib/python-mcdb/README

mcdb removes the 4GB limit inherent in cdb. mcdb 消除了 cdb 中固有的 4GB 限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM