5
4
I work with a lot of tab-delimited data files, with varying columns of uncertain length.
Typically, the way people view these files is to bring them down from the server to their Windows or Mac machine, and then open them up in Excel. This is certainly fully-featured, allowing filtering and other nice options. But sometimes, you just want to look at something quickly on the command line.
I wrote a bare-bones utility to display the first<n>
lines of a file like so:
--- line 1 ---
1:{header-1} 2:{header-2} 3:...
--- line 2 ---
1:{data-1} 2:{data-2} 3:...
This is, obviously, very lame, but it's enough to pipe through grep, or figure out which header columns to use "cut -f" on.
Is there a *nix-based viewer for a terminal session which will display rows and columns of a tab-delimited file and let you move the viewing window over the file, or otherwise look at data?
I don't want to write this myself; instead, I'd just make a reformatter which would replace tabs with spaces for padding so I could open the file up in emacs and see aligned columns. But if there's already a tool out there to do something like this, that'd be great!
(Or, I could just live with Excel.)
psc
doesn't like columns with more than 1021 characters in them. That's a problem for me. I'd like something really robust for viewing (not editing) delimited files like this. I have made my own scripts, but they're not ideal. – Aaron McDaid – 2015-07-10T10:40:00.963That sounds very promising! It seems to have led me down the rabbit-hole of figuring out where to get sc, and why my Fedora installation isn't seeing all package upgrades, but that's not anyone else's problem. Thanks! – Michael H. – 2010-05-12T18:48:50.483
That works very well, thank you! Especially for the psc suggestion. Now I just wish I knew how to pass tab as the single delimiter character to psc... – weronika – 2012-01-01T03:33:20.563
@weronika: If
-d '\t'
doesn't work, try-d $'\t'
– Paused until further notice. – 2012-01-01T03:51:32.897@Dennis: Yes, I figured that out eventually. :) Great solution, I use this all the time now. – weronika – 2012-01-28T06:16:49.250