CSV Data Explorer
What This Does
A CLI tool to explore, analyze, and visualize CSV data directly from the terminal. Load CSV files, filter rows, calculate statistics, generate summaries, and create basic visualizations without leaving your terminal.
Key features:
- - Load and preview CSV files with automatic delimiter detection
- Explore data structure - view columns, data types, missing values
- Filter rows based on conditions (equality, inequality, contains, regex)
- Select columns - include/exclude specific columns
- Calculate statistics - mean, median, min, max, standard deviation, percentiles
- Generate summaries - count, unique values, frequency distributions
- Basic visualizations - histograms, bar charts, scatter plots (ASCII or simple terminal output)
- Export results - filtered data, statistics, summaries to new CSV/JSON files
- Interactive mode - step-by-step exploration with prompts
- Command-line mode - scriptable operations for automation
When To Use
- - You need to quickly explore CSV data without opening spreadsheets
- You want to filter and analyze data for reporting or debugging
- You need to calculate basic statistics on datasets
- You're working on servers/remote machines without GUI tools
- You want to automate CSV data processing in scripts
- You need to share analysis results with team members
- You're teaching data analysis concepts in terminal environment
Usage
Basic commands:
CODEBLOCK0
Examples
Example 1: Preview and basic statistics
CODEBLOCK1
Output:
CODEBLOCK2
Example 2: Filter and calculate statistics
CODEBLOCK3
Output:
CODEBLOCK4
Example 3: Generate histogram
CODEBLOCK5
Output (ASCII approximation):
CODEBLOCK6
Example 4: Interactive mode
CODEBLOCK7
Interactive mode guides you through:
- 1. File loading and preview
- Column selection and filtering
- Statistical analysis
- Visualization options
- Export results
Requirements
- - Python 3.x
- INLINECODE0 library for data manipulation (installed automatically or via pip)
- INLINECODE1 library for visualizations (optional, for enhanced charts)
Install missing dependencies:
CODEBLOCK8
Limitations
- - Large files (>100MB) may be slow to process
- Visualizations are ASCII-based or simple terminal plots
- No support for Excel files or other formats (CSV only)
- Limited to basic statistical functions (not advanced analytics)
- No support for time series analysis or complex aggregations
- Memory usage scales with file size
- No built-in support for database connections
- No support for streaming/processing very large datasets
- Visualizations limited to terminal capabilities
- No support for geographic data or maps
- Limited error handling for malformed CSV files
- No built-in data cleaning or transformation functions
- Performance may be slower than specialized tools like R or specialized libraries
Directory Structure
The tool works with CSV files in the current directory or specified paths. No special configuration directories are required.
Error Handling
- - Invalid CSV files show helpful error messages with line numbers
- Missing columns suggest available column names
- Type conversion errors show expected vs actual types
- Memory errors suggest using smaller files or filtering first
- File not found errors suggest checking path and permissions
Contributing
This is a skill built by the Skill Factory. Issues and improvements should be reported through the OpenClaw project.
CSV 数据探索器
功能概述
一款命令行工具,可直接在终端中探索、分析和可视化 CSV 数据。无需离开终端即可加载 CSV 文件、筛选行、计算统计量、生成摘要并创建基础可视化图表。
主要功能:
- - 加载和预览 CSV 文件,自动检测分隔符
- 探索数据结构 - 查看列、数据类型、缺失值
- 基于条件筛选行(等于、不等于、包含、正则表达式)
- 选择列 - 包含/排除特定列
- 计算统计量 - 均值、中位数、最小值、最大值、标准差、百分位数
- 生成摘要 - 计数、唯一值、频率分布
- 基础可视化 - 直方图、条形图、散点图(ASCII 或简单终端输出)
- 导出结果 - 将筛选数据、统计量、摘要导出为新的 CSV/JSON 文件
- 交互模式 - 通过提示逐步探索
- 命令行模式 - 可编写脚本的操作,便于自动化
适用场景
- - 需要快速探索 CSV 数据但不想打开电子表格时
- 希望筛选和分析数据以进行报告或调试时
- 需要对数据集计算基本统计量时
- 在没有图形界面工具的服务器或远程机器上工作时
- 希望在脚本中自动化 CSV 数据处理时
- 需要与团队成员分享分析结果时
- 在终端环境中教授数据分析概念时
使用方法
基本命令:
bash
加载并预览 CSV 文件
python3 scripts/main.py preview data.csv
显示基本统计量
python3 scripts/main.py stats data.csv
筛选 age 列大于 30 的行
python3 scripts/main.py filter data.csv --where age > 30
选择特定列
python3 scripts/main.py select data.csv --columns name,age,salary
为某列生成直方图
python3 scripts/main.py histogram data.csv --column age --bins 10
统计某列的唯一值
python3 scripts/main.py unique data.csv --column category
导出筛选后的数据
python3 scripts/main.py filter data.csv --where salary > 50000 --output filtered.csv
交互式探索模式
python3 scripts/main.py interactive data.csv
示例
示例 1:预览和基本统计量
bash
python3 scripts/main.py preview sales.csv --limit 10
输出:
CSV 文件:sales.csv(1000 行 × 5 列)
前 10 行:
┌─────┬────────────┬───────────┬────────┬───────────┐
│ 行号 │ 日期 │ 产品 │ 金额 │ 区域 │
├─────┼────────────┼───────────┼────────┼───────────┤
│ 1 │ 2024-01-01 │ 部件 A │ 150.50 │ 北部 │
│ 2 │ 2024-01-01 │ 部件 B │ 89.99 │ 南部 │
│ ... │ ... │ ... │ ... │ ... │
└─────┴────────────┴───────────┴────────┴───────────┘
列摘要:
- - 日期:1000 非空,类型:日期时间
- 产品:1000 非空,类型:字符串(5 个唯一值)
- 金额:1000 非空,类型:浮点数(最小值:10.00,最大值:999.99)
- 区域:1000 非空,类型:字符串(4 个唯一值)
示例 2:筛选并计算统计量
bash
python3 scripts/main.py filter sales.csv --where Region == North and Amount > 100 --stats
输出:
筛选后的数据:237 行(共 1000 行)
筛选数据的统计量:
- - 计数:237
- 金额均值:245.67
- 金额中位数:210.50
- 金额最小值:101.00
- 金额最大值:999.99
- 标准差:145.23
示例 3:生成直方图
bash
python3 scripts/main.py histogram sales.csv --column Amount --bins 5
输出(ASCII 近似):
金额分布(5 个区间):
[10.00 - 207.99] ████████████████████████████ 312
[208.00 - 405.99] ████████████████████ 241
[406.00 - 603.99] ██████████ 152
[604.00 - 801.99] █████ 78
[802.00 - 999.99] ███ 45
示例 4:交互模式
bash
python3 scripts/main.py interactive sales.csv
交互模式将引导您完成:
- 1. 文件加载和预览
- 列选择和筛选
- 统计分析
- 可视化选项
- 导出结果
系统要求
- - Python 3.x
- pandas 库用于数据处理(自动安装或通过 pip 安装)
- matplotlib 库用于可视化(可选,用于增强图表)
安装缺失依赖:
bash
pip3 install pandas matplotlib
局限性
- - 大文件(>100MB)处理可能较慢
- 可视化基于 ASCII 或简单的终端绘图
- 不支持 Excel 文件或其他格式(仅 CSV)
- 仅限基本统计函数(不支持高级分析)
- 不支持时间序列分析或复杂聚合
- 内存使用量随文件大小增加
- 不支持数据库连接
- 不支持流式处理或处理超大数据集
- 可视化受限于终端能力
- 不支持地理数据或地图
- 对格式错误的 CSV 文件错误处理有限
- 没有内置的数据清洗或转换函数
- 性能可能低于 R 等专业工具或专用库
目录结构
该工具适用于当前目录或指定路径下的 CSV 文件。无需特殊配置目录。
错误处理
- - 无效的 CSV 文件会显示包含行号的有用错误信息
- 缺失的列会建议可用的列名
- 类型转换错误会显示预期类型与实际类型
- 内存错误会建议使用较小的文件或先进行筛选
- 文件未找到错误会建议检查路径和权限
贡献
此技能由技能工厂构建。问题和改进应通过 OpenClaw 项目报告。