命令行CSV查看器? [关闭]

本文翻译自:Command line CSV viewer? [closed]

Anyone know of a command-line CSV viewer for Linux/OS X? 有人知道Linux / OS X的命令行CSV查看器吗? I'm thinking of something like less but that spaces out the columns in a more readable way. 我想的一样东西less更可读的方式,但该位出列。 (I'd be fine with opening it with OpenOffice Calc or Excel, but that's way too overpowered for just looking at the data like I need to.) Having horizontal and vertical scrolling would be great. (我可以用OpenOffice Calc或Excel打开它,但这样做太强大了,以至于只按需要查看数据即可。)进行水平和垂直滚动会很棒。


#1楼

参考:https://stackoom.com/question/7RQR/命令行CSV查看器-关闭


#2楼

I wrote a script, viewtab , in Groovy for just this purpose. 为此 ,我在Groovy中编写了一个脚本viewtab You invoke it like: 您可以像这样调用它:

viewtab filename.csv

It is basically a super-lightweight spreadsheet that can be invoked from the command line, handles CSV and tab separated files, can read VERY large files that Excel and Numbers choke on, and is very fast. 它基本上是一个超轻量级电子表格,可以从命令行调用,处理CSV和制表符分隔的文件,可以读取Excel和Numbers阻塞的非常大的文件,并且速度非常快。 It's not command-line in the sense of being text-only, but it is platform independent and will probably fit the bill for many people looking for a solution to the problem of quickly inspecting many or large CSV files while working in a command line environment. 从纯文本的意义上讲,它不是命令行,但它是平台独立的,可能适合许多正在寻找在命令行环境中工作时快速检查许多或大型CSV文件问题的解决方案的人。

The script and how to install it are described here: 脚本及其安装方法如下:

http://bayesianconspiracy.blogspot.com/2012/06/quick-csvtab-file-viewer.html http://bayesianconspiracy.blogspot.com/2012/06/quick-csvtab-file-viewer.html


#3楼

Tabview: lightweight python curses command line CSV file viewer (and also other tabular Python data, like a list of lists) is here on Github Tabview:轻量级的Python curses命令行CSV文件查看器(以及其他表格Python数据,如列表列表)在Github上

Features: 特征:

  • Python 2.7+, 3.x Python 2.7 +,3.x
  • Unicode support Unicode支持
  • Spreadsheet-like view for easily visualizing tabular data 类似于电子表格的视图,可轻松可视化表格数据
  • Vim-like navigation (h,j,k,l, g(top), G(bottom), 12G goto line 12, m - mark, ' - goto mark, etc.) 类似于Vim的导航(h,j,k,l,g(顶部),G(底部),12G goto第12行,m-标记,'--goto标记等)
  • Toggle persistent header row 切换永久标题行
  • Dynamically resize column widths and gap 动态调整列宽和间隙的大小
  • Sort ascending or descending by any column. 按任何列升序或降序排列。 'Natural' order sort for numeric values. 数值的“自然”顺序排序。
  • Full-text search, n and p to cycle between search results 全文搜索,n和p在搜索结果之间循环
  • 'Enter' to view the full cell contents 按“ Enter”查看完整的单元格内容
  • Yank cell contents to clipboard 将单元格内容拖到剪贴板
  • F1 or ? F1还是? for keybindings 用于键绑定
  • Can also use from python command line to visualize any tabular data (eg list-of-lists) 还可以从python命令行使用可视化任何表格数据(例如列表列表)

#4楼

这是一个(可能也是)简单的选项:

sed "s/,/\t/g" filename.csv | less

#5楼

我的FOSS项目CSVfix可让您以“ ASCII艺术”表格格式显示CSV文件。


#6楼

Ofri's answer gives you everything you asked for. Ofri的答案将为您提供所需的一切。 But.. if you don't want to remember the command you can add this to your ~/.bashrc (or equivalent): 但是..如果您不想记住该命令,可以将其添加到〜/ .bashrc(或等效项)中:

csview()
{
local file="$1"
sed "s/,/\t/g" "$file" | less -S
}

This is exactly the same as Ofri's answer except I have wrapped it in a shell function and am using the less -S option to stop the wrapping of lines (makes less behaves more like a office/oocalc). 这是完全一样Ofri的答案,除了我在一个shell函数包裹,并使用我less -S选项停止线的包装(使less的行为更像是一个办公/ oocalc里)。

Open a new shell (or type source ~/.bashrc in your current shell) and run the command using: 打开一个新的shell(或在当前shell中键入source ~/.bashrc )并使用以下命令运行命令:

csview <filename>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值