Reputation: 13055
After opening a big csv file in gvim, how can I know how many columns are within this file?
Upvotes: 3
Views: 139
Reputation: 172698
The csv.vim plugin provides a lot of functionality to work with CSV data. It includes a :NrColumns
command.
Upvotes: 4
Reputation: 40947
A quick dirty hack would be to do something like:
:s/,//gn
Which would give you the number of commas on a single row. Add one and you have your number of columns (assuming no trailing comma, of course).
I say this is quick and dirty because it doesn't take into account quoted columns which can contain commas. I'm sure there might be a way to take that into account with a regex but it's probably not trivial.
Upvotes: 3