0

I have 3 txt files (file1.txt, file2.txt, file3.txt), that contains JSON formatted data. The size of the files like something like this:

file1 = 104.55 Mb
file2 = 104.68 Mb
file3 = 104.49 Mb

I can open and read file1 and file3 without any problems, but when I try to open file2 I'm getting a MemoryError despite its size is almost the same as the others, the difference is less than 200KB.

Here is my implementation for opening the files:

with open(file1.txt, encoding="utf-8") as f:
    jsonContent = json.load(f)

json_data = json.dumps(jsonContent)
file_data = json.loads(json_data)

I would really appreciate if somebody could tell me what can cause this issue, because everything seems fine for me and I can't believe that 200KB is the reason. Am I doing something wrong in my code or it is what it looks like, I don't have enough memory?

gatto
  • 333
  • 2
  • 10

1 Answers1

0

It's always hard to say exactly what's causing the issue; but this question has been asked before, usually replied to with links to iJSON or json streamer.

I won't say that's the defacto solution for you, but the question is common. If you go the iJSON route, please look at this post and the thread around it.

Community
  • 1
  • 1
Wolfie
  • 143
  • 6