Skip to content

Instantly share code, notes, and snippets.

@scls19fr
Last active February 18, 2018 09:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scls19fr/8a7a9fba691230ca55aebeee33c59ca8 to your computer and use it in GitHub Desktop.
Save scls19fr/8a7a9fba691230ca55aebeee33c59ca8 to your computer and use it in GitHub Desktop.
import os
import json
import pandas as pd
def main():
print("Summary omercy!")
lst = []
for root, dirs, files in os.walk('.', topdown=False):
for name in files:
if os.path.splitext(name)[1] == '.json':
with open(os.path.join(root, name), 'r') as fd:
data = json.load(fd)
lst.append(data)
df = pd.DataFrame(lst)
df = df.sort_values(['topic', 'title'])
# 'author', 'author_bio', 'cover', 'description', 'epub', 'isbn', 'mobi', 'pdf', 'source', 'title', 'topic'
df = df[['topic', 'title', 'author', 'description', 'author_bio', 'cover', 'epub', 'isbn', 'mobi', 'pdf', 'source']]
# print(df)
filename = "summary_omercy.csv"
print("Write summary to %s" % filename)
df.to_csv(filename, index=False)
filename = "summary_omercy.xlsx"
print("Write summary to %s" % filename)
df.to_excel(filename, index=False)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment