esv/json-to-tsv.py

18 lines
468 B
Python
Raw Normal View History

2024-03-04 22:20:06 +00:00
#!/usr/bin/env python3
import json
import pandas
from flatten_json import flatten
f = open('ESV.json')
json_list = json.load(f)
key_list = ['book', 'chapter', 'verse', 'text']
json_list = [{k:d[k] for k in key_list} for d in json_list]
# Flatten and convert to a data frame
json_list_flattened = (flatten(d, '.') for d in json_list)
df = pandas.DataFrame(json_list_flattened)
export_csv = df.to_csv('esv.tsv', sep='\t', encoding='utf-8', index=None, header=True)