Datasets:
HiTZ
/

Modalities:
Text
Formats:
json
ArXiv:
Tags:
legal
Libraries:
Datasets
pandas
License:
EusExams / configs.py
juletxara's picture
add dataset configs to readme
bd9bf59
raw
history blame
950 Bytes
import os
import re
folder_path = "data"
langs = ["eu", "es"]
output = "configs:\n"
for lang in langs:
for root, dirs, files in os.walk(f"{folder_path}/{lang}"):
for file in sorted(files):
file_path = os.path.join(root, file)
rel_path = os.path.relpath(file_path, folder_path)
output += (
f"- config_name: {lang}_{os.path.splitext(file)[0]}\n data_files:\n"
)
output += f' - split: test\n path: "{rel_path}"\n'
# read existing contents of README.md
with open("README.md", "r") as f:
readme_content = f.read()
# find end of YAML header using regular expressions
yaml_end = re.search(r"---\n\n", readme_content).start()
# insert generated YAML output after YAML header
readme_content = readme_content[:yaml_end] + output + readme_content[yaml_end:]
# write updated contents to README.md
with open("README.md", "w") as f:
f.write(readme_content)