0

I have multiple json files:

data_part1.json
data_part2.json
data_part3.json
...

They are written like this:

{"transaction_id":203019326,"amount":2.4,"user_invoice_date":"2018-11-19"}
{"transaction_id":261491169,"amount":2.4,"user_invoice_date":"2019-02-20"}
{"transaction_id":294748592,"amount":2.4,"user_invoice_date":"2019-03-30"}

I already tried to read the first file:

openfile=open('path')                          
jsondata=json.load(openfile)
df=pd.DataFrame(jsondata)

openfile.close()

But I get the following error: JSONDecodeError: Expecting ',' delimiter: line 2 column 1 (char 77)

How to read these files into data frame?

milka1117
  • 521
  • 4
  • 8
  • 17
  • do you try `jsondata=pd.read_json(file, lines=True)` ? – jezrael Sep 26 '19 at 08:20
  • It's not "weird" JSON, it's [JSONLines](http://jsonlines.org/). This format is growing and for good reason; having the line delimiter means that massive files can be iterated without loading the whole file into memory like conventional JSON. In this instance that fact isn't important, since you want a DF of the whole file, but it has other uses – roganjosh Sep 26 '19 at 08:27

0 Answers0