Loading...
Loading...
Compare original and translation side by side
Tool Selection by File Size:
├── < 100MB → pandas
├── 100MB - 1GB → pandas with chunking or polars
├── 1GB - 10GB → DuckDB or polars
├── > 10GB → DuckDB, Spark, or streaming
└── Quick exploration → csvkit or xsv CLI
Processing Type:
├── SQL-like queries → DuckDB
├── Complex transforms → pandas/polars
├── Simple filtering → csvkit/xsv
└── Streaming → Python csv module按文件大小选择工具:
├── < 100MB → pandas
├── 100MB - 1GB → pandas(分块处理)或 polars
├── 1GB - 10GB → DuckDB 或 polars
├── > 10GB → DuckDB、Spark 或 流处理
└── 快速探索 → csvkit 或 xsv CLI
按处理类型选择:
├── 类SQL查询 → DuckDB
├── 复杂转换 → pandas/polars
├── 简单过滤 → csvkit/xsv
└── 流处理 → Python csv 模块| Anti-Pattern | Problem | Correct Approach |
|---|---|---|
| Loading all to memory | OOM on large files | Use chunking or streaming |
| Guessing encoding | Corrupted characters | Detect with chardet first |
| Ignoring quoting | Broken field parsing | Use proper CSV parser |
| No validation | Silent data corruption | Validate row/column counts |
| Manual string splitting | Breaks on edge cases | Use csv module or pandas |
| 反模式 | 问题 | 正确做法 |
|---|---|---|
| 全量加载至内存 | 大型文件导致内存不足 | 使用分块或流处理 |
| 猜测编码 | 字符损坏 | 先用chardet检测编码 |
| 忽略引号处理 | 字段解析失败 | 使用合适的CSV解析器 |
| 不进行验证 | 数据静默损坏 | 验证行/列数量 |
| 手动字符串拆分 | 边缘场景下出错 | 使用csv模块或pandas |