360 Secure SkillHub
360 安全技能中心

text-parser

该 Skill 以指南形式提供用 Python 解析结构化文本文件的方法:按行读取内容,按冒号分割键值对,去除行首短横线,将结果存入字典,供后续匹配 PDF 标签使用。文档给出常见输入格式示例和若干提示,未包含 PDF 生成或填充的实现代码。

wu-uk
wu-uk
热度 36.77
最近更新 2026-05-11 17:43:14
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add edit-pdf-text-parser
Metadata
name
text-parser
description
Guide for parsing structured text input files.

Text Parser Skill

Overview

Parse structured text files to extract data for filling PDFs.

Key-Value Parsing

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"

Common Input Formats

- Name: John Smith
- Email: john@example.com
- Phone: 555-1234

Or without dashes:

Name: John Smith
Email: john@example.com

Tips

  • Read the entire input file first
  • Match field names to PDF labels
  • Handle special instructions