Skip to content

Commit

Permalink
Add missing tests/json2md.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyang2057 committed Aug 21, 2023
1 parent 14d662e commit 5ef157b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/json2md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import argparse
import json
import pandas as pd


def json2md(json_file):
json_list = []
with open(json_file, 'r') as f:
json_list = json.load(f)

json_list = sorted(json_list, key=lambda d: d['case'])
df = pd.DataFrame.from_records(json_list)
md = df.to_markdown()
md_file = json_file.split('/')[-1].split('.')[0] + '.md'

with open(md_file, 'w') as f:
f.write(md)


if __name__ == '__main__':
parser = argparse.ArgumentParser(prog="json2md")
parser.add_argument("--json", help='json file', type=str)
args = parser.parse_args()
json2md(args.json)

0 comments on commit 5ef157b

Please sign in to comment.