0

I would like to view my CSV files in a column-aligned format from the command line, with something like less, but my CSV files are sometimes gigabytes big, and I'm using a little computer (Netbook, 1GB RAM, 8GB HD, 1GHz processor), so I don't want to waste a lot of memory or processing power viewing the file.

I mention that I'd like to use something like less because I would like to be able to navigate around within the file.

cat FILE | column -s, -t | less is one thought, but cat is still going to try to print the whole file and I'm not sure how much buffering the pipes will use (if any) or what sort of caching less employs.

This question is similar to this other question, but I'm specifically interested in viewing large files using minimal resources preferably already on the machine. I don't presently use VI or EMACS, and think they'd both be overkill here. VI, for instance, would be a 27MB install for a utility acting merely as a viewer.

Community
  • 1
  • 1
Richard
  • 56,349
  • 34
  • 180
  • 251
  • VIM actually buffers the file as needed. It's pretty light on resources. I even use gVim on windows which works really well. Just my 2 cents. – Ali Aug 16 '11 at 20:29
  • Thanks, @Ali. I keep hearing of the goodness of VIM, but it would be a 27.1MB download onto a computer which only has 54MB to spare. This seems space-expensive for a tool I'd be using only as a viewer. – Richard Aug 16 '11 at 20:32
  • vim binary is <2MB. (And it is 7h3 b3s7 3d170r 3v3r!!!1) – stnr Aug 16 '11 at 20:51
  • @stavnir, VIM the Ubuntu repository package weighs in at ~28.2MB. Not sure what to do about this. – Richard Aug 16 '11 at 20:56

2 Answers2

2

First of all, less can open oversized files. Second, both vim (which I use with the Largefile plugin and with files over 8 GB) and emacs can do it. But... Most of the time, viewing a big file in a 80x40 (or a bit bigger) terminal is useless... so you should filter it with something like (f)grep or process it with awk. If you want only the start or end, then there are head and tail.

HTH

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
  • Perhaps my question was ambiguous (I've clarified it). I would like to view big files using a small, navigable viewer (like less) in a column-aligned format. `head` and `tail` don't provide this. – Richard Aug 16 '11 at 20:36
1

Check the tail \ head commands.

Or even better, Download VIM source and compile it. That should be easy enough. Version 5.8 source is 1Mb before decompressing (4MB after). Enjoy.

stnr
  • 435
  • 4
  • 14
  • This is a quick and dirty solution, but doesn't allow navigation within the file. – Richard Aug 16 '11 at 20:30
  • And this will provide a nicely-formatted way to view the CSV? – Richard Aug 16 '11 at 21:46
  • @stavnir: It's been a long time since I've been able to use `vim`. Do the new versions support the `:set leftright` found in `nvi` (I think that is right). Setting that value would tell `nvi` NOT to wrap the text on the screen, and you could scroll left and right (with the `w,W,$` and normal vi navigation keys (Not mouse input!)). I recall using this feature to look at files that where ~5000 chars wide. This still doesn't solve @Richard s need to expand text on CSV columns. Can emacs do it all, he asked rethorically ;-) Good luck to all. – shellter Aug 17 '11 at 20:41