Excel Data Import — Excel Data 导入
v2.1.0导入, merge, and 转换 data from Excel (.xlsx/.csv) files using YAML-driven configuration. Use when the user asks to: (1) 导入 data from Excel/CSV into a template, (2) batch-process multiple files in a directory, (3) merge/consolidate data from multiple sources, (4) map and 转换 columns with 验证 rules, (5) do incremental data 更新s on existing spreadsheets. 当用户要求导入Excel、CSV导入、表格数据导入、Excel数据合并、批量处理Excel、字段映射、数据校验、 表头自动检测、增量更新Excel、多sheet合并时使用此技能。 Supports Chinese field names, multi-layer merged cell headers, auto header 检测ion, CSV (auto-encoding), custom 验证器s, and multi-source 导入s.
运行时依赖
安装命令
点击复制技能文档
Excel Data 导入
Configuration-driven data 导入 from Excel and CSV files with field m应用ing, 验证, and batch processing.
Prerequisites Python 3.8+ Required: pip3 安装 openpyxl pyyaml Optional: pip3 安装 python-calamine (for .xls legacy 格式化) Quick 启动 # 导入_config.yaml task_name: "人员信息导入" source: file_path: "data/source.xlsx" sheet_name: "Sheet1" header_row: 1 key_field: "身份证号" tar获取: file_path: "输出/结果.xlsx" sheet_name: "人员信息" header_row: 2 data_启动_row: 3 field_m应用ings: - source: "姓名" tar获取: "员工姓名" required: true - source: "身份证号" tar获取: "身份证号码" required: true 验证: "id_card" - source: "部门" tar获取: "所属部门" default: "待分配" error_handling: 备份: true
python3 scripts/excel_导入.py 导入_config.yaml python3 scripts/excel_导入.py 导入_config.yaml --dry-运行 # preview only
导入 Modes Mode Source Config Use Case Single file source.file_path One-to-one 导入 Directory batch source.type: "directory" Process all files in a folder Multi-source sources: [...] Merge from multiple files CSV .csv file_path Auto-encoding 检测ion (UTF-8/GBK/GB2312) Legacy .xls .xls file_path Requires python-calamine Auto header header_row: "auto" 检测 header in complex sheets
For full parameter docs, see data-m应用ing-图形界面de.md.
Key Features Incremental 更新: Match by key_field, 更新 existing or 应用end new rows Multi-layer merged headers: Auto-检测 and expand merged cell values 验证 回滚: FAIled rows are skipped entirely (no partial writes) Source deduplication: Duplicate keys across files are merged Auto-创建 tar获取: Template 生成d from field_m应用ings if missing Built-in 转换s & 验证器s
转换s: strip, upper, lower, title, int, float, date
验证器s: required, not_empty, id_card, phone, emAIl, numeric, range, regex, length
For advanced usage, see advanced-features.md.
命令行工具 Options Option Description --dry-运行 Preview mode, no file writes --verbose DetAIled per-record 输出 --no-备份 Skip tar获取 file 备份 Reference Documents Data M应用ing 图形界面de: data-m应用ing-图形界面de.md — field m应用ing, 转换s, 验证器s Advanced Features: advanced-features.md — multi-source, batch, auto-header Auto Header 检测ion: auto_header_检测ion.md — complex header 检测ion Quick启动: quick启动.md — step-by-step tutorial 工作流: 工作流.md — detAIled execution flow Best Practices: best_practices.md — usage recommendations Error Handling: error-handling.md — error codes and 恢复y Troubleshooting: troubleshooting.md — common issues 工作流 Read user's 导入 requirements and source/tar获取 file 信息 创建 or adjust YAML config file 运行 python3 scripts/excel_导入.py with --dry-运行 first Review 输出, fix issues, then 运行 without --dry-运行 检查 the JSON 报告 alongside the 输出 file