0

I downloaded geo data from a site that has them set up in text files. When I copy paste these files into excel, they show up in each individual column:

enter image description here

My main problem with excel is that it is very bad with large data. My data file is 100+ MB. Therefore, I use MacVim. MacVim shows the data like so:

enter image description here

How can I delete or even select a column of data using MacVim. Is there a way to distinguish columns using MacVim in the same way that excel distinguishes them?

Thank you, your help is much appreciated

Community
  • 1
  • 1
user3565264
  • 157
  • 2
  • 10
  • vim is a text editor. I do not believe it has any mechanism for handling data column wise. If you want to delete columns you should be able to use `cut` http://stackoverflow.com/questions/13690461/using-cut-command-to-remove-multiple-columns – FDinoff Mar 05 '15 at 04:39
  • Very nice, but how do recognize the column to cut. The example shows simple columns such as 1,2,3,4 ... but my vim shows '123123 name 234 234 123 asd 12 asdsd', not necessary random, but hard to differ – user3565264 Mar 05 '15 at 04:45

3 Answers3

1

There seems to be a nice library for dealing with csv files within vim at: https://github.com/chrisbra/csv.vim

I'd also suggest looking at the csvkit tools by Chris Groskopf: https://csvkit.readthedocs.org/

Daniel Lathrop
  • 191
  • 1
  • 8
0

Make the invisible tab character look like "| " using listchars setting. That way, it'll get easier to visually distinguish columns. Then, you can use blockwise visual mode to select columns. This may still not work in cases where the columns are not aligned correctly due to the length of text in previous cells. You can solve that by potentially replacing one tab by two tabs, but then you will see less data, obviously.

Sinatra
  • 820
  • 6
  • 13
0

The columns are apparently TAB separated.

  • To delete the first column, you can :%s/\S*\t//

  • To delete the e. g. 4th column, you can :%s/\(\(\S*\t\)\{3}\)\S*\t*/\1/

  • To delete all but the e. g. 4th column, you can :%s/\(\S*\t\)\{3}\(\S*\).*/\2/

  • To delete all but the first column, you can :%s/\(\S*\).*/\1/

Armali
  • 18,255
  • 14
  • 57
  • 171