-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcreate_datasets_md.py
More file actions
29 lines (23 loc) · 973 Bytes
/
create_datasets_md.py
File metadata and controls
29 lines (23 loc) · 973 Bytes
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
'''
target: create a python script to automate the datasets.md file updation every time there is change in the data folder files.
This folder should not be changes unless the related changes are updated in this script.
Avoid spaces while naming the file/folder
# '''
import os
data_path = os.path.join(".", "Data") # ./Data
with open("DATASETS.md", 'w') as mdFile:
mdFile.write("## All DATASETS.\n")
for root, folders, files in os.walk(data_path):
if len(files)> 0:
baseName = os.path.basename(root)
mdFile.write(f"### {baseName.upper()}\n")
for f in files:
title = f.split(".")[0].upper()
link = os.path.join(root, f)
while "\\" in link:
link = link.replace("\\", "/")
content = f"[{title}]({link})\n\n"
mdFile.write(content)
mdFile.write("\n")
mdFile.write("\n")
mdFile.close()