Reputation: 409
I have a json file with non valid lines. I read it using this code
import json
import pandas as pd
data = []
with open('json file ') as f:
for line in f:
data.append(json.loads(line))
Sorry about the ugly looking code, I' m using the mobile Stack Exchange app. What I would like to do is to convert the data object into a data frame which columns are the first 5 elements of each data object list. Can you help? Cheers!
Dani
Upvotes: 1
Views: 3273
Reputation: 409
I feel a little bit ashamed. It is as easy as using the Dataframe method:
df = pd.DataFrame(data)
Upvotes: 6