I have a directory full of JSON files that I need to extract information from and convert into a Pandas dataframe. My current solution works, but I have a feeling that there is a more elegant way of doing this:
for entry in os.scandir(directory):
if entry.path.endswith(".json"):
with open(entry.path) as f:
data = json.load(f)
...
newline = field1 + ',' + field2 + ',' + ... + ',' + fieldn
output.append(newline)
...
df = pd.read_csv(io.StringIO('\n'.join(output)))
databeing used?pd.read_jsonandpd.concat