有人知道Linux/OS X的命令行CSV查看器吗?我在考虑一些更少的东西,但以一种更可读的方式分隔列。(我可以用OpenOffice Calc或Excel打开它,但这对于我需要查看的数据来说太强大了。)有水平和垂直滚动会很棒。


当前回答

在python中有一个简短的命令行脚本:https://github.com/rgrp/csv2ascii/blob/master/csv2ascii.py

只需下载并放置在您的路径。用法就像

csv2ascii.py [options] csv-file-path

转换csv文件在csv-file-path到ascii形式返回的结果 stdout。如果csv-file-path = '-'则从stdin读取。

选项:

  -h, --help            show this help message and exit
  -w WIDTH, --width=WIDTH
                        Width of ascii output
  -c COLUMNS, --columns=COLUMNS
                        Only display this number of columns

其他回答

安装csvtool(在Ubuntu上)

sudo apt-get install csvtool

然后运行:

csvtool readable filename | view -

这将使它在只读的vim实例中非常漂亮,即使您有一些具有非常长的值的单元格。

还有另一个多功能的CSV(不仅仅是)操作工具:Miller。从它自己的描述来看,它类似于名称索引数据(如CSV、TSV和表格JSON)的awk、sed、cut、join和sort。(链接到github仓库:https://github.com/johnkerl/miller)

如果你是一个vimmer,使用CSV插件,它非常漂亮:

.

在python中有一个简短的命令行脚本:https://github.com/rgrp/csv2ascii/blob/master/csv2ascii.py

只需下载并放置在您的路径。用法就像

csv2ascii.py [options] csv-file-path

转换csv文件在csv-file-path到ascii形式返回的结果 stdout。如果csv-file-path = '-'则从stdin读取。

选项:

  -h, --help            show this help message and exit
  -w WIDTH, --width=WIDTH
                        Width of ascii output
  -c COLUMNS, --columns=COLUMNS
                        Only display this number of columns

XSV不仅仅是一个查看器。我推荐它用于命令行上的大多数CSV任务,特别是在处理大型数据集时。