name: text-parser description: "Guide for parsing structured text input files."
Parse structured text files to extract data for filling PDFs.
def parse_input(text):
"""Parse key-value pairs from text."""
data = {}
for line in text.strip().split('\n'):
if ':' in line:
# Remove leading dash/bullet if present
line = line.lstrip('- ').strip()
key, value = line.split(':', 1)
data[key.strip()] = value.strip()
return data
# Usage
with open("input.txt") as f:
content = f.read()
data = parse_input(content)
# data["Name"] -> "John Smith"
# data["Email"] -> "john@example.com"
- Name: John Smith
- Email: john@example.com
- Phone: 555-1234
Or without dashes:
想要更強大的技能外掛,就來小蔥技能站7w4.net看看吧。
Name: John Smith
Email: john@example.com
這個Skill提供了基礎的文本解析功能,程式碼示例清晰直觀,對簡單鍵值對格式的解析做得不錯。但整體內容較為簡單,對複雜格式和異常情況的處理能力有限,文件末尾有截斷感。適合需要處理基礎文本解析的場景,但如果遇到較為複雜的資料格式可能會遇到困難。