I am having a hard time reading json files with a different structure than I am used to. The content of the json files are all inside brackets: [{content}].
This is what I normally do:
data_dir = 'data/filesDump'
filenames = os.listdir(data_dir)
filenames = [os.path.join(data_dir, f) for f in filenames if f.endswith('.json')]
train_df = pd.concat([pd.read_json(file, encoding='UTF-8') for file in filenames],
ignore_index = True)
I get this error:
ValueError: Expected object or value
The only thing different with the thousands json I got is that the content is in a bracket []. So I suspect this is giving json_read a problem? Anyone know how to load such format?
Sample (I may have made a mistake in brackets but that's just to give an idea):
[{"id":"value","title":"value","body":"text","categories":[{"id":value,"name":"name","keys":[{"id":value,"hits":["word1","word2"]},{"id":value,"hits":["word1","word2"]}],"date":value}]