I want to read json file using python pandas. Each line of the file is a complete object in JSON.
I'm using below versions-
python : 2.7.6
pandas: 1.19.1
json file-
{"id":"111","p_id":"55","name":"aaa","notes":"","childs":[]}
{"id":"222","p_id":"56","name":"bbb","notes":"","childs":[]}
{"id":"333","p_id":"75","name":"ccc","notes":"","childs":[]}
{"id":"444","p_id":"76","name":"ddd","notes":"","childs":["abc","efg","pqr"
,"rtu"]}
I'm using below code to read json file-
df = pd.read_json("temp.txt", lines = True)
print df
The problem is, in json file "childs" key contains a array of not known indexes and in between "\n" is available. so if I run above code I'm getting ValueError: Expected object or value but if I remove "\n" available after "pqr" my code gets work.
I don't want to remove available "\n" from my data. I want to handle this within my code. I want to use python pandas only instead of python json libraries for handling data in good manner.
How I can make use of python pandas only and handle this type of file?