0

I'm currently working with a largish (2 gig) json file that I need to parse into Python.

The problem is that some of the data is improperly escaped, which is giving me an error.

Here is my code

import json

data = []
with open('full.json') as f:
for line in f:
    data.append(json.loads(line))

which is giving me the following error

ValueError: Invalid \escape: line 1 column 64 (char 63)

I printed out the file and found the line that is giving me trouble

{"page_viewed":"Truck Repair Form - \342\204\242"}

I know its the \342\204\242 section that is holding me back, I just need to figure out how to properly escape the backslashes.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
jasnonaz
  • 57
  • 5

0 Answers0