无法解压缩python中的大blob

2024-06-08 23:06:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试使用python从Oracle中提取压缩的blob并将其解压缩。但较大的水滴并没有完全减压。在

我尝试过使用数据帧和文件来存储blob,然后解压缩它们,但是它不能转换更大的blob。记忆是可能的问题吗?我可以尝试哪些改变?在

我不能共享这些blob作为它的受限数据。我没有权限创建测试数据。在

我使用下面的git解压代码进行解压,这对较小的blob非常有效

https://github.com/joeatwork/python-lzw/blob/master/lzw/init.py

下面是我的示例代码:

sql_string = """select 
event_id
,blob_length
,blob field

 from table"""

cur.execute(sql_string)
path = "P:/Folders/"

    for row in cur:
        print('de-BLOBbing {}..\n')
        filename = path +  "clinical_notes_" + str(row[0]) + "_" + str(row[1]) + ".txt"      
        filename1 = path1 +  "clinical_notes_" + str(row[0]) + "_" + str(row[1]) + ".txt"      
        f = open(filename, "wb")
        f.write(row[3].read())
        f.close()
        h = html2text.HTML2Text()
        h.ignore_links=True
        blobbytes = row[3].read()
        f2 = h.handle(striprtf(decompress_without_eoi(blobbytes)))
        f1 = codecs.open(filename1, encoding='utf-8', mode='wb+')
        f1.write(f2)
        f1.close()

另外,如果我把它们放在下面的数据帧中,它显示了关于结构和内存使用的信息,其中is_blob是blob字段。 enter image description here


Tags: 数据path代码txtsqlstringfilenameblob