Last active
February 18, 2018 09:13
-
-
Save s-celles/8a7a9fba691230ca55aebeee33c59ca8 to your computer and use it in GitHub Desktop.
Résumé dans fichier Excel ou CSV de https://gist.github.com/Krazybug/1ae50814d25b0a1d862dfdf7161ee503
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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