I have a file file1.json whose contents are like this (each dict in a separate line):
{"a":1,"b":2}
{"c":3,"d":4}
{"e":9,"f":6}
.
.
.
{"u":31,"v":23}
{"w":87,"x":46}
{"y":98,"z":68}
I want to load this file into a pandas dataframe, so this is what i did:
df = pd.read_json('../Dataset/file1.json', orient='columns', lines=True, chunksize=10)
But this instead of returning a dataframe returns a JSONReader.
[IN]: df
[OUT]: <pandas.io.json.json.JsonReader at 0x7f873465bd30>
Is it normal, or am i doing something wrong? And if this is how read_json() is supposed to behave when there're multiple dictionaries in a single json file (without being any comma separated) and with each dict in a separate line, then how can i best fit them into a dataframe?
EDIT:
if i remove the chunksize paramter from the read_json() this is what i get:
[IN]: df = pd.read_json('../Dataset/file1.json', orient='columns', lines=True)
[OUT]: ValueError: Expected object or value
chunksizedoes. see the doc: pandas.pydata.org/pandas-docs/stable/io.html#io-jsonlValueError: Expected object or valuealso it doesn't recognize the file as valid json object as each dictionary is separated by a new line characterlines=True, so you were telling it that you had a single JSON text rather than a file full of line-delimited JSON texts, which isn't true, so it gives you an error. But if that's not it, create a new question.