I'm receiving an error when trying to insert_many

OverflowError: MongoDB can only handle up to 8-byte ints

I’m using a find() to get data from a collection then I’m looping and inserting it into an api call and pushing the values in the response to a new collection.

I works but then I get those error when it reaches a larger number of records.

Any ideas on how to fix?

Please check these links


Thanks. So it looks like it’s due to the letter ‘E’ being parsed and returned as a scientific notation, e+.

So a value of 5E62 is coming in as an exponential number, 5e+62. I took the json response and converted it to a string and did a replace(“e”,“E”), which it seemed to work. But then when I converted it back to json it reverted it back to the exponential number. I’m using ast.literal_eval(string) to convert back to json.

Is there a way to keep the “E” and not have it convert back when converting back to json?

Thanks.
Phuong

It reverts back when I convert a string to a dictionary so I can import it into the database.

I figured out how to get around it, I pulled the key and put quotes around the values. That seemed to keep the data in tact.

Hi @Phuong_Hoang, welcome!

Could you elaborate more on what you’re trying to insert into MongoDB i.e. example of value ?
Also, it would be useful to know what your intention of usage of the field’s value. i.e. are you going to run further computation/calculation on the value ?

Regards,
Wan.