← 返回
未分类

Excel Data Import

Import, merge, and transform data from Excel (.xlsx/.csv) files using YAML-driven configuration. Use when the user asks to: (1) import data from Excel/CSV in...
使用 YAML 配置文件从 Excel (.xlsx/.csv) 文件导入、合并和转换数据。适用于:1) 从 Excel/CSV 导入数据
aqbjqtd aqbjqtd 来源
未分类 clawhub v2.1.0 1 版本 99890.6 Key: 无需
★ 0
Stars
📥 913
下载
💾 200
安装
1
版本
#latest

概述

Excel Data Import

Configuration-driven data import from Excel and CSV files with field mapping, validation, and batch processing.

Prerequisites

  • Python 3.8+
  • Required: pip3 install openpyxl pyyaml
  • Optional: pip3 install python-calamine (for .xls legacy format)

Quick Start

# import_config.yaml
task_name: "人员信息导入"
source:
  file_path: "data/source.xlsx"
  sheet_name: "Sheet1"
  header_row: 1
  key_field: "身份证号"
target:
  file_path: "output/result.xlsx"
  sheet_name: "人员信息"
  header_row: 2
  data_start_row: 3
field_mappings:
  - source: "姓名"
    target: "员工姓名"
    required: true
  - source: "身份证号"
    target: "身份证号码"
    required: true
    validate: "id_card"
  - source: "部门"
    target: "所属部门"
    default: "待分配"
error_handling:
  backup: true
python3 scripts/excel_import.py import_config.yaml
python3 scripts/excel_import.py import_config.yaml --dry-run   # preview only

Import Modes

ModeSource ConfigUse Case
------------------------------
Single filesource.file_pathOne-to-one import
Directory batchsource.type: "directory"Process all files in a folder
Multi-sourcesources: [...]Merge from multiple files
CSV.csv file_pathAuto-encoding detection (UTF-8/GBK/GB2312)
Legacy .xls.xls file_pathRequires python-calamine
Auto headerheader_row: "auto"Detect header in complex sheets

For full parameter docs, see data-mapping-guide.md.

Key Features

  • Incremental update: Match by key_field, update existing or append new rows
  • Multi-layer merged headers: Auto-detect and expand merged cell values
  • Validation rollback: Failed rows are skipped entirely (no partial writes)
  • Source deduplication: Duplicate keys across files are merged
  • Auto-create target: Template generated from field_mappings if missing

Built-in Transforms & Validators

Transforms: strip, upper, lower, title, int, float, date

Validators: required, not_empty, id_card, phone, email, numeric, range, regex, length

For advanced usage, see advanced-features.md.

CLI Options

OptionDescription
---------------------
--dry-runPreview mode, no file writes
--verboseDetailed per-record output
--no-backupSkip target file backup

Reference Documents

Workflow

  1. Read user's import requirements and source/target file info
  2. Create or adjust YAML config file
  3. Run python3 scripts/excel_import.py with --dry-run first
  4. Review output, fix issues, then run without --dry-run
  5. Check the JSON report alongside the output file

版本历史

共 1 个版本

  • v2.1.0 当前
    2026-03-30 13:07 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 382 📥 145,423
office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 929 📥 187,021
office-efficiency

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 458 📥 152,939