Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
780 views
in Technique[技术] by (71.8m points)

python 3.x - 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. 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? 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...