VisiData 终极生存指南(vd)
# 🛠️ VisiData (vd) 终极生存指南
一句话简介:VisiData 是终端里的“交互式 Excel”,能极速处理 GB 级的 JSON、CSV、Excel 和数据库文件,是硬核开发者分析数据的降维打击工具。
# Opening Files
https://jsvine.github.io/intro-to-visidata/basics/opening-files/ (opens new window)
vd <file>
vd - < sample.tsv
# launch the DirSheet, navigate to the file you wish to load, and press Enter.
vd .
# 把当前系统所有运行中的进程详细列表,直接管道输送给 VisiData (vd) 进行交互式表格解析
ps aux | vd
# specify the file’s format。 打开两个文件,并指定格式
vd -f csv data.txt -f "" other.jsonl
# Loading sources supported by pandas
vd -f pandas data.parquet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# Compatible filetypes
# 追加打开
操作步骤
- 在当前 VisiData 界面中,按下 o(小写字母 o,代表 Open)。
- 此时屏幕底部会弹出输入框 open: ,并带有路径补全功能。
- 输入你想追加的文件路径(支持相对路径或绝对路径,如 ../data/new_stock.csv),然后回车。
- 效果:新文件会立刻被加载并展现在你面前。
# navigation (opens new window)
- move faster
gj: to last rowgk: to first rowgh: to leftmost columngl: to rightmost columnControl-F: one page down (forward)Control-B: one page up (backward)
- move via searching
n: Move to next matching row;N: Move to previous matching rowc + regex: Jump to the next matching column
- move to a specific row/column number
zr + n: Jump to row number nzc + n: Jump to column number n
Alt + H: 帮助U: 撤销最近的修改,跟VIM一样
快捷键不需要刻意记,使用下面方案可能是一种比较好的选择
使用 tmux 分屏打开vd的帮助文档,具体操作如下:
- 进入tmux window. 使用
C-b + %开启左右分屏 - 定位到新开的pane中,屏使用
vd -h | vim -专门用于搜索快捷键。这样就不用记这些快捷键了。
这样就可以左边使用vd工作操作数据,右边查vd相关的命令啦
# sheets
# Understanding Sheets (opens new window)
Shift-S: open the Sheets Sheet from anywhere in VisiDatagS: open Sheets Sheet, which contains all sheets from current session, active and inactiveControl-^: Quickly toggling between sheets: flip back and forth between your current sheet and the previous one- rename a sheet
e: 在Sheets列表中,选中sheet,然后按此键
# columns
# Understanding Columns (opens new window)
c + <column_name>: 跳转到column- view all columns and their attributes
Shift-C
- rename a column
^
- expand, shrink, and remove columns
_: Expands the width of current column to fit text in all visible rows-: hide the current columngv: unhide all columns on current sheetz-: Shrinks the current column’s width in half
- manipulate columns
!: pins the current column on the left as a key columnH L: slides the current column one position to the left/rightgH gL: slides the current column all the way to the left/right of its section
- expand columns that contain nested data
(: expand current column): contract (unexpand) the current column
- create derivative columns
=: takes a Python expression as input and creates a new column- 自定义配置命令: 强大, 可以在帮助列表中查找到
# Set column types
| 快捷键 (Command) | 数据类型 (Type) | 备注/适用场景 |
|---|---|---|
~ | string | 字符串/文本格式(默认) |
# | int | 整数类型(适合数量、ID等) |
% | float | 浮点数类型(适合带小数点的比例、指标) |
$ | currency | 货币类型 |
@ | date | 日期类型(时间序列分析必备) |
z# | vlen | 变长/向量长度类型 |
z~ | anytype | 任意/混合类型 |
# createing new columns (opens new window)
# create an expression column
DEMO: 根据list_date一列,过滤出在2000年上市的公司
- 将光标移动到
list_date这一列上,按下快捷键@。把这一列的每一行都当做真正的 Pythondatetime.date对象来理解 - 输入
=list_date.year < 2000,然后按Enter.
# create new columns by splitting another one
- navigate to that column, and press
:.
# reshaping Data (opens new window)
# other
# suspend and recovery
需要说明操作的不是vd独有的,使用了macOs的内置命令完成
Ctrl + Z: 触发 suspendjobs: 查看当前后台所有任务fg %1: 回到前台, 指定序号的job,捞回前台
# 2.4.3 数据统计与筛选
不用写复杂的 SQL 或 Python 脚本,几个按键搞定报表统计。
- 频率统计 (Frequency):选中一列,按
Shift + F。- 用途:瞬间生成该列数据的分布图,一眼看出哪些值出现次数最多。
- 快速排序:按
[(升序) 或](降序)。 - 正则筛选:
- 按
|输入正则,匹配的行会变色(被选中)。 - 按
"(双引号),新开一个窗口只显示刚才选中的行。
- 按
- 数值计算:按
+后输入sum/avg/max,在底部状态栏查看结果。
# 2.5 使用 pyobj
Ctrl+X:evaluate Python expression and open result as Python object
示例1:查找注册资本(reg_capital)大于 500,000 的企业
- 移动光标至
reg_capital列,按下#(或%) 转换为数字类型。 - 按下快捷键
Ctrl + x唤出底部 Python 输入框。 - 输入
[r for r in sheet.rows if r.reg_capital > 500000]并回车,即可生成独立的过滤结果对象表。
💡 小贴士:在 VisiData 中遇到困难?随时按下
Ctrl + H唤起内置帮助文档。
# link
上次更新: 2026/05/21, 21:58:29
- 01
- cloudeflare06-07
- 03
- macOS 定时任务实现:Git 仓库状态自动同步方案04-26