Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a big (multi-gigabyte) CSV file, which I am viewing with a puny computer.

I would like to view my file using less or some command like it which doesn't have to read the whole file at once to show me part of it.

Is there a command out there which can show me my file in comma-aligned columns?

share|improve this question
    
This question appears to be abandoned, if you are experiencing a similar issue please ask a new question with details pertaining to your problem. If you feel this question is not abandoned, please flag the question explaining that. :) –  jrg Feb 23 '12 at 21:02
add comment

closed as too localized by jrg Feb 23 '12 at 21:02

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

There is a csv column formatting question on another StackOverflow site - does this work for your very-large file?

cat somefile.csv | column -s, -t | less -#2 -N -S
share|improve this answer
    
This will not work. Because cat will try to print the entire file, which may be gigabytes worth of data. It may be that there's a buffer somewhere in the pipes which prevents this situation, but I'm not sure and a complete answer using cat would have to address this. If there were such a buffer, I'd begin to wonder if the data was then being cached by less. –  Richard Aug 16 '11 at 20:21
    
ok - please add this comment to your question - it will give a better understanding that you are manipulating big=multi gigabytes!! –  fossfreedom Aug 16 '11 at 20:23
    
I'd assumed that big was a sufficient descriptor! I'll make a note of that, thanks. –  Richard Aug 16 '11 at 20:27
    
Can you use tail or head instead of cat to get the last 10 or first 10 records, then pipe that into column? head file.csv | column <options> | less <options>. I am not sure if head or tail will read the entire file THEN output the desired rows... –  SaultDon Aug 16 '11 at 20:39
add comment

I just tried vim with a 514M text file. It has 8032416 lines and after it loaded for around 30 seconds, I could run around the file very smoothly.

It took 30% of my 2GB RAM, and vim created a 2.2M swap file. Sounds reasonable.

tail gave me instant results on that file, it probably seeks to the bottom and then goes up until it reaches 10 lines and then prints them.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.