Anyone know of a command-line CSV viewer for Linux/OS X? I'm thinking of something like less
but that spaces out the columns in a more readable way. (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.
相关问题
- Is shmid returned by shmget() unique across proces
- sqlyog export query result as csv
- how to get running process information in java?
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
Have a look at csvkit. It provides a set of tools that adhere to the UNIX philosophy (meaning they are small, simple, single-purposed and can be combined).
Here is an example that extracts the ten most populated cities in Germany from the free Maxmind World Cities database and displays the result in a console-readable format:
Csvkit is platform independent because it is written in Python.
Here's a (probably too) simple option:
Tabview: lightweight python curses command line CSV file viewer (and also other tabular Python data, like a list of lists) is here on Github
Features:
Ofri's answer gives you everything you asked for. But.. if you don't want to remember the command you can add this to your ~/.bashrc (or equivalent):
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 (makesless
behaves more like a office/oocalc).Open a new shell (or type
source ~/.bashrc
in your current shell) and run the command using:csview <filename>
You can also use this:
column
is a standard unix program that is very convenient -- it finds the appropriate width of each column, and displays the text as a nicely formatted table.Note: whenever you have empty fields, you need to put some kind of placeholder in it, otherwise the column gets merged with following columns. The following example demonstrates how to use
sed
to insert a placeholder:Note that the substitution of
,,
for, ,
is done twice. If you do it only once,1,,,4
will become1, ,,4
since the second comma is matched already.Tabview is really good. Worked with 200+MB files that displayed nicely which were buggy with LibreOffice as well as csv plugin in gvim.
The Anaconda version is available here: https://anaconda.org/bioconda/tabview