-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtablegenerator.py
57 lines (47 loc) · 1.73 KB
/
tablegenerator.py
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
49
50
51
52
53
54
55
56
57
import glob
import sys
import os
import json
import pandas as pd
from pathlib import Path
def check_jsons(path):
result = []
for f in glob.glob(path):
print(f)
with open(f, "rb") as infile:
result.append(json.load(infile))
print(result)
table = pd.DataFrame(val for sublist in result for val in sublist)#.transpose()
return table.to_html()
table = []
table.append('## Summary showing which points from the checklist are fulfilled by studies.\n')
path = os.path.join('papers_checklist', "*.json")
table.append(check_jsons(path))
table.append('\n\n## Summary showing which points from the checklist are fulfilled by data resources.')
path = os.path.join('datasets_checklist', "*.json")
table.append('\n')
table.append(check_jsons(path))
table.append('\n\n## This table presents the data sources. The JPEG quality factor (QF) for most images has been set to 75, other cases are indicated.')
path = os.path.join('datasets_information', "*.json")
table.append('\n')
table.append(check_jsons(path))
readme_file = []
with open('README.md', 'r') as readme:
readme = readme.readlines()
save = True
for line in readme:
if line == '<!--START_SECTION:data-section-->\n':
save = False
readme_file.append('<!--START_SECTION:data-section-->\n')
for item in table:
readme_file.append(item)
elif line == '<!--END_SECTION:data-section-->\n':
save = True
readme_file.append('\n<!--END_SECTION:data-section-->\n')
elif save == True:
readme_file.append(line)
print('\n')
#with open('README.md','w') as f:
# f.write(''.join(readme_file))
p = Path('README.md')
p.write_text(''.join(str(v) for v in readme_file))