blob: 646b0b4822bd3b6bb3691dd1c30fe1a29b021c42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# This script reads the JSON data from the input file and creates a Markdown file for each entry in the JSON data.
import json
import os
#change
input_dir = '../public/jsonData/home.json'
output_dir = './content/home/core'
output_fileName = 'core'
with open(input_dir, 'r', encoding='utf-8') as file:
data = json.load(file)
os.makedirs(output_dir, exist_ok=True)
#change
for count, entry in enumerate(data["coreteam"], start=1):
#change
Number = count
name = entry['name']
positions = entry['position']
institute = entry['institute']
# positions_content = '\n'.join([f' - "{position}"' for position in positions])
# Create the content for the Markdown file
content = f"""---
Number: {Number}
name: "{name}"
position: {positions}
institute: "{institute}"
---
"""
filename = os.path.join(output_dir, f"{output_fileName}{count}.md")
count+=1
with open(filename, 'w', encoding='utf-8') as md_file:
md_file.write(content)
print("Markdown files created successfully.")
|