🚀 CSV Editor - 基於MCP的AI驅動CSV處理工具
CSV Editor 是一款高性能的MCP服務器,它能讓Claude、ChatGPT等AI助手通過簡單命令實現強大的數據操作能力,徹底改變AI助手處理CSV數據的方式。
🚀 快速開始
快速演示
"加載銷售數據並去除重複項"
"篩選2024年第四季度交易額超過10000美元的交易記錄"
"計算價格和數量之間的相關性"
"用中位數填充缺失值"
"將分析結果導出為Excel文件"
通過Smithery安裝
要通過 Smithery 為Claude Desktop自動安裝 csv-editor,請執行以下命令:
npx -y @smithery/cli install @santoshray02/csv-editor --client claude
最快安裝方式(推薦)
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/santoshray02/csv-editor.git
cd csv-editor
uv sync
uv run csv-editor
配置你的AI助手
Claude Desktop(點擊展開)
在macOS系統中,將以下內容添加到 ~/Library/Application Support/Claude/claude_desktop_config.json 文件中:
{
"mcpServers": {
"csv-editor": {
"command": "uv",
"args": ["tool", "run", "csv-editor"],
"env": {
"CSV_MAX_FILE_SIZE": "1073741824"
}
}
}
}
其他客戶端(Continue、Cline、Windsurf、Zed)
詳細配置請參考 MCP_CONFIG.md。
✨ 主要特性
解決的問題
AI助手在處理複雜數據操作時面臨困難,它們雖然可以讀取文件,但缺乏有效過濾、轉換、分析和驗證CSV數據的工具。
解決方案
CSV Editor彌補了這一差距,它為AI助手提供了40多種專門用於CSV操作的工具,使其成為強大的數據分析師,能夠:
- 數秒內清理雜亂的數據集
- 執行復雜的統計分析
- 自動驗證數據質量
- 使用自然語言命令轉換數據
- 通過撤銷/重做功能跟蹤所有更改
關鍵差異化特性
| 特性 |
CSV Editor |
傳統工具 |
| AI集成 |
原生MCP協議 |
手動操作 |
| 自動保存 |
具備多種策略的自動保存 |
需要手動保存 |
| 歷史記錄跟蹤 |
帶快照的完整撤銷/重做功能 |
有限或無此功能 |
| 會話管理 |
多用戶隔離會話 |
單用戶 |
| 數據驗證 |
內置質量評分 |
需要單獨的工具 |
| 性能 |
通過分塊處理GB級以上的文件 |
存在內存限制 |
💻 使用示例
基礎用法
"Load the sales data and remove duplicates"
"Filter for Q4 2024 transactions over $10,000"
"Calculate correlation between price and quantity"
"Fill missing values with the median"
"Export as Excel with the analysis"
高級用法
數據分析師工作流
session = load_csv("daily_sales.csv")
remove_duplicates(session_id)
change_column_type("date", "datetime")
fill_missing_values(strategy="median", columns=["revenue"])
get_statistics(columns=["revenue", "quantity"])
detect_outliers(method="iqr", threshold=1.5)
get_correlation_matrix(min_correlation=0.5)
export_csv(format="excel", file_path="clean_sales.xlsx")
ETL管道
load_csv_from_url("https://api.example.com/data.csv")
filter_rows(conditions=[
{"column": "status", "operator": "==", "value": "active"},
{"column": "amount", "operator": ">", "value": 1000}
])
add_column(name="quarter", formula="Q{(month-1)//3 + 1}")
group_by_aggregate(group_by=["quarter"], aggregations={
"amount": ["sum", "mean"],
"customer_id": "count"
})
export_csv(format="parquet")
export_csv(format="json")
數據質量保證
validate_schema(schema={
"customer_id": {"type": "integer", "required": True},
"email": {"type": "string", "pattern": r"^[^@]+@[^@]+\.[^@]+$"},
"age": {"type": "integer", "min": 0, "max": 120}
})
quality_report = check_data_quality()
anomalies = find_anomalies(methods=["statistical", "pattern"])
📚 詳細文檔
可用工具
完整工具列表(40多種工具)
I/O操作
load_csv - 從文件加載
load_csv_from_url - 從URL加載
load_csv_from_content - 從字符串加載
export_csv - 導出到各種格式
get_session_info - 獲取會話詳情
list_sessions - 列出活動會話
close_session - 清理會話
數據操作
filter_rows - 複雜過濾
sort_data - 多列排序
select_columns - 列選擇
rename_columns - 重命名列
add_column - 添加計算列
remove_columns - 刪除列
update_column - 更新值
change_column_type - 類型轉換
fill_missing_values - 處理空值
remove_duplicates - 去重
分析
get_statistics - 統計摘要
get_column_statistics - 列統計信息
get_correlation_matrix - 相關性矩陣
group_by_aggregate - 分組操作
get_value_counts - 頻率計數
detect_outliers - 查找異常值
profile_data - 數據剖析
驗證
validate_schema - 模式驗證
check_data_quality - 質量指標
find_anomalies - 異常檢測
自動保存和歷史記錄
configure_auto_save - 設置自動保存
get_auto_save_status - 檢查狀態
undo / redo - 導航歷史記錄
get_history - 查看操作記錄
restore_to_operation - 時光回溯
配置
環境變量
| 變量 |
默認值 |
描述 |
CSV_MAX_FILE_SIZE |
1GB |
最大文件大小 |
CSV_SESSION_TIMEOUT |
3600s |
會話超時時間 |
CSV_CHUNK_SIZE |
10000 |
處理塊大小 |
CSV_AUTO_SAVE |
true |
啟用自動保存 |
自動保存策略
CSV Editor可以通過可配置的策略自動保存你的工作:
- 覆蓋(默認) - 更新原始文件
- 備份 - 創建帶時間戳的備份
- 版本化 - 維護版本歷史
- 自定義 - 保存到指定位置
configure_auto_save(
strategy="backup",
backup_dir="/backups",
max_backups=10
)
高級安裝選項
其他安裝方法
使用pip
git clone https://github.com/santoshray02/csv-editor.git
cd csv-editor
pip install -e .
使用pipx(全局安裝)
pipx install git+https://github.com/santoshray02/csv-editor.git
從GitHub安裝(推薦)
pip install git+https://github.com/santoshray02/csv-editor.git
uv pip install git+https://github.com/santoshray02/csv-editor.git
pip install git+https://github.com/santoshray02/csv-editor.git@v1.0.1
🔧 技術細節
運行測試
uv run test
uv run test-cov
uv run all-checks
項目結構
csv-editor/
├── src/csv_editor/ # 核心實現
│ ├── tools/ # MCP工具實現
│ ├── models/ # 數據模型
│ └── server.py # MCP服務器
├── tests/ # 測試套件
├── examples/ # 使用示例
└── docs/ # 文檔
🤝 貢獻代碼
我們歡迎貢獻!請參考 CONTRIBUTING.md 獲取貢獻指南。
快速貢獻指南
- 分叉倉庫
- 創建功能分支
- 編寫測試並進行更改
- 運行
uv run all-checks
- 提交拉取請求
📈 路線圖
- [ ] SQL查詢接口
- [ ] 即時協作
- [ ] 高級可視化
- [ ] 機器學習集成
- [ ] 雲存儲支持
- [ ] 針對10GB以上文件的性能優化
💬 支持
📄 許可證
本項目採用MIT許可證,請參閱 LICENSE 文件獲取詳細信息。
🙏 致謝
本項目基於以下工具構建:
準備好提升你的AI數據處理能力了嗎? 兩分鐘內開始使用 →