Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python memory error with f.read

I have problem with memory in python "Python memory error". In fact , I try to recover data from a big .bson file using this script:

with open('xxxx.bson','rb') as f:
    data = bson.decode_all(f.read())

error message :

data = bson.decode_all(f.read())
MemoryError

thank you for any help you can provide

like image 981
krayni anis Avatar asked Jan 17 '26 22:01

krayni anis


1 Answers

You can reduce memory consumption by switching to decode_file_iter, which 1) requires a file (not its contents) as input, and 2) returns a generator.

like image 192
Sergei Lebedev Avatar answered Jan 19 '26 14:01

Sergei Lebedev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!