From 1aca03a09e8e25984b633b38de8b2d4def01a347 Mon Sep 17 00:00:00 2001 From: Elihuso Quigley Date: Fri, 22 Nov 2024 09:18:48 +0800 Subject: [PATCH] [+] Add export script --- people/tdor/comments/.gitignore | 1 + people/tdor/comments/export.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 people/tdor/comments/.gitignore create mode 100644 people/tdor/comments/export.py diff --git a/people/tdor/comments/.gitignore b/people/tdor/comments/.gitignore new file mode 100644 index 00000000..eb75d570 --- /dev/null +++ b/people/tdor/comments/.gitignore @@ -0,0 +1 @@ +export.md \ No newline at end of file diff --git a/people/tdor/comments/export.py b/people/tdor/comments/export.py new file mode 100644 index 00000000..f38f971f --- /dev/null +++ b/people/tdor/comments/export.py @@ -0,0 +1,19 @@ +import os +import json + +md = '' + +for dirpath, dirName, fileName in os.walk("./"): + for f in fileName: + if f.lower().endswith('.json'): + with open('./' + f, 'r') as file: + data = json.load(file) + md += str(data['content']).replace('\n', ' \n').replace('\\n', '\n\n') + md += '\n\n' + md += '——' + str(data['submitter']) + md += '



\n\n' + +print(md) +m = open('./export.md', 'w') +m.write(md) +m.close() \ No newline at end of file