Run1 parse key value text
Parses a text file containing key-value pairs (like question IDs and question text) into a Python dictionary.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill run1_parse-key-value-textAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.2 KB, 222 tokens by cl100k_base, as published. Nobody here has run it
When reading a file that contains keys and values representing distinct items (e.g., q1: What is the company name?), you can extract them into a Python dictionary by iterating through the file and splitting each line by a predefined delimiter.
def parse_key_value_file(file_path, delimiter=":"):
"""
Reads a file with key-value pairs and returns a dictionary.
Args:
file_path (str): The path to the text file.
delimiter (str): The character separating the key and the value.
"""
parsed_data = {}
with open(file_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if not line:
continue
# Split only on the first occurrence of the delimiter
if delimiter in line:
key, value = line.split(delimiter, 1)
parsed_data[key.strip()] = value.strip()
else:
# Handle cases where the format might differ or fallback
pass
return parsed_data
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.