Data Split By Field
Documentsdata_split_by_fieldData Split By Field is an Agent Skill for documents published in the cas-bigdatalab/piflow repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
按字段拆分数据工具。根据指定字段的值将结构化表格拆分为多个文件,每个唯一值对应一个输出文件。 当用户提到数据拆分、按字段分组导出、分类导出、数据分片、按某列值分割文件等需求时使用此skill。 即使用户没有明确说出"拆分",只要任务涉及将结构化表格按某字段值分成多个文件,就应该使用此skill。 不负责字段聚合统计、行级过滤或跨表关联合并。
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/data_split_by_field/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/data-split-by-field, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Data Split By Field 按字段拆分数据 Skill
功能概述
本skill用于根据指定字段的值将结构化表格拆分为多个文件。每个唯一的字段值会生成一个独立的输出文件, 文件名包含字段值以便识别。
触发条件
当用户请求以下任务时,应使用此skill:
- 按字段拆分数据
- 分组导出
- 分类导出
- 数据分片
- 按某列值分割文件
核心参数说明
必需参数
--input:输入文件路径--output_dir:输出目录路径--split_field:用于拆分的字段名
可选参数
--output_prefix:输出文件名前缀,默认split--output_format:输出文件格式,默认csv--use_dask:是否使用Dask处理大数据,默认False--blocksize:Dask分块大小,默认64MB
输入文件格式
输入文件可以是 CSV、TSV、Excel 或 SPSS 文件,且必须包含 split_field 对应的列。
使用方法
python scripts/run_data_split_by_field.py --input data.csv --output_dir ./output --split_field category
输出示例
[OK] Data split completed!
Engine: pandas
Input file: data.csv
Split field: category
Total rows: 1000
Unique values: 5
Output files:
- ./output/split_cat1.csv (200 rows)
- ./output/split_cat2.csv (300 rows)
环境要求
- Python 3.10+
- pandas
- openpyxl、xlrd、pyreadstat 等按输入格式需要安装
- 可选:dask
注意事项
- 拆分字段必须存在于数据中
- 输出文件名格式为:
{prefix}_{field_value}.{format} - 字段值中的特殊字符会被替换为下划线
- 输出目录不存在时会自动创建