Delete column of data from MacVim - excel

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:
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:
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

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/

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.

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/

Related

plotting data from a txt file with excel

I have a text file that I will upload it. I wanna to select just 2 columns and then plot it with something like excel!
the problem is that when i want to select a column, those things that selected, is not just one column. I try it to open with excel. however it opened but there was same problem again. I'm just wanna select all data of one column and then plot it.
I can not even copy or a paste a certain data. all data will copy instead.
My English is not adequate, I know. Hope to could convey my mean.
Any help will be appreciated.
file
In excel, select the first column which should contain all the columns from your text file.
In the excel menus (or using the search field), select « convert ». Then chose the type « delimiter », and select the delimiter in your excel file. Either a comma, or a tabulation, etc.
Click ok and this should do the trick

Csv writer escape semicolon python [duplicate]

I am using Excel for Mac 2016 on macOS Sierra software. Although I have been successfully copying and pasting CSV files into excel for some time now, recently, they have begun to behave in an odd way. When I paste the data, the content of each row seems to split over many columns. Where as before one cell would have been able to contain many words, it seems now as though each cell is only able to contain one word, so it splits the content of what would normally be in one cell, over many cells, making some rows of data spread out over up to 100 columns!
I have tried Data tab>> From text>> which takes me through a Text Wizard. There I choose Delimited>> Choose Delimiters: Untick the 'Space' box ('Tab' box is still ticked)>> Column data as 'General'>> Finish. Following this process appears to import the data into its correct columns. It works. BUT, a lot of work to get there!
Question: Is there any way to change the default settings of Delimiters, so that the 'Space' delimiter does not automatically divide the data?
I found an answer! It has to do with the "Text to Columns" function:
The way fix this behavior is:
Select a non-empty cell
Do Data -> Text to Columns
Make sure to choose Delimited
Click Next >
Enable the Tab delimiter, disable all the others
Clear Treat consecutive delimiters as one
Click Cancel
Now try pasting your data again
I did the opposite regarding "consecutive delimiters"!
I put a tick in the box next to "Treat consecutive delimiters as one", and THEN it worked.
Choose delimiter directly in CSV file to open in Excel
For Excel to be able to read a CSV file with a field separator used in a given CSV file, you can specify the separator directly in that file. For this, open your file in any text editor, say Notepad, and type the below string before any other data:
To separate values with comma: sep=,
To separate values with semicolon: sep=;
To separate values with a pipe: sep=|
In a similar fashion, you can use any other character for the delimiter - just type the character after the equality sign.
For example, to correctly open a semicolon delimited CSV in Excel, we explicitly indicate that the field separator is a semicolon:
reference

Excel pasting data issue

Hi all i have been conducting research using JNNS creating neural networks.
I have collected my results inside a result file and wish to create graphs with them to clearly present my findings in a report.
My issue is when pasting the result file contents (expected outputs and then actual outputs) into excel the whole set of results goes into the A1 column instead of spreading across multiple rows
Does anyone know how i would go about fixing this issue?
Example to aid question:
1.1 Expected result / actual result
0, 0, 1, 0
0.02501, 0.00013, 0.99952, 0
and pasting this into excel does this:
https://gyazo.com/38c089ebcfaca7b85d31caacd3e950f9
instead of this:
https://gyazo.com/22f1527df18e811871e53402cea4ab2f
Thanks
I am guessing your data is in a CSV format, do you have notepad++?
if you do open it there and click on the show all characters, i wanna know what do you have at the end of your lines CR or LF...
Thanks to OmarQA for the help, i needed to paste my data into a text file, replace all spaces with commas using the replace tool, then import data from text on excel and use comma as data separation and it solved the issue!
Thanks
It might be that excel's not recognizing the proper delimiter when you're pasting you data. On Excel, select the cell with the entire text (in your picture, cell A1) and go to the Data tab. Look for a button called "Convert text to columns" or something like that. It will open a new window asking you for parameters (delimiters, if comma is a decimal separator, etc) and it gives you a preview of how your data is going to look like with that setting. Just mess around a little bit and you should get your data good to go. Looking at your picture, it might be possible that you didn't select "tab" as a delimiter.

HH:MM:SS:MS Formatting in excel

I have a lot of data in the form of
"00:00:03:19"
(hh:mm:ss:milliseconds)
I can not do much with it since excel is interpreting the data as text. Under "format cells/custom"
I can not find an appropriate entry for the data.... How can I teach/show excel what kind of data I am processing there?
I'm afraid the only option for Excel to read that properly is to somehow replace the last colon : with a decimal point. It's not until Excel understood your data as expected that you can think of the appropriate display format.
How are you receiving this data? If you can have all these values aligned in a single column in a csv file for example, by using a good text editor like Notepad++ you could select all the last : with ALT + mouse, replace them all at once, and finally load that into Excel.
One option is:
=SUBSTITUTE(A1,":",".",3)
select, Copy, Paste Special, Values then Text to Columns with Tab as the delimiter.
I found another solution!
I pasted the timevalues into the A column and split it via the LEFT,MID RIGHT comands
(eg:00:00:01:21 in A3)
A---------------------B-----------------C----------------D---------------E-----------------------F--------
00:00:01:21 -- LEFT(A3;2) -- MID(A3;4;2) -- MID(A3;7;2) -- (RIGHT(A3;2)) -- E3+(D3*1000)+(C3*60000)+(B3*3600000)

how to work with csv files in vim

I want csv file to be opened in vim in the same way it opens in microsoft office . Data should be in column format and commas should not be seen and its should be traversed easily. Is it possible in vim with help of any plug-ins?
I am probably a little bit later answering that question, but for completeness I'll answer anyway. I have made the csv plugin that should make it possible to do what you want.
Among others, it allows:
Display on which column the cursor is as well as number of columns
Search for text within a column using :SearchInColumn command
Highlight the column on which the cursor is using :HiColumn command
Visually arrange all columns using :ArrangeColumn command
Delete a Column using :DeleteColumn command
Display a vertical or horizontal header line using :Header or :VHeader command
Sort a Column using :Sort command
Copy Column to register using :Column command
Move a column behind another column using :MoveCol command
Calculate the Sum of all values within a column using :SumCol command (you can also define your own custom aggregate functions)
Move through the columns using the normal mode commands (W forwards, H backwards, K upwards, J downwards)
sets up a nice syntax highlighting, concealing the delimiter, if your Vim supports it
I've tried Christian's csv plugin, and it is useful for quick looks at csv files, especially when you need to look at many different files.
However, when I'm going to be looking at the same csv file more than a few times, I import the file into sqlite3, which makes further analysis much faster and easier to perform.
For instance, if my file looks like this:
file.csv:
field1name, field2name, field3name
field1data, field2data, field3data
field1data, field2data, field3data
I create a new sqlite db (from the command line):
commandprompt> sqlite3 mynew.db
Then create a table in the db to import the file into:
sqlite> create table mytable (field1name, field2name, field3name);
sqlite> .mode csv
sqlite> .headers ON
sqlite> .separator ,
sqlite> .import file.csv mytable
Now the new table 'mytable' contains the data from the file, but the first row is storing the header, which you don't typically want, so you need to delete it (use single quotes around the field value; if you use double quotes you'll delete all rows):
sqlite> delete from mytable where field1name = 'field1name';
Now you can easily look at the data, filter by complex formulas, sort by multiple fields, etc.
sqlite> select * from mytable limit 30;
(Sorry this turned into a sqlite tutorial but it seems like every time that I don't import into sqlite, I end up spending much more time using vim/less/grep/sort/cut than I would have had I just imported in the first place).
There's also exist rainbow_csv vim plugin. It will highlight csv/tsv file columns in different "rainbow" colors and will allow you to write SQL-like SELECT and UPDATE queries using Python or JavaScript expressions.
You probably want to look at sc as an alternative.. Have a look at this linux journal page
Here's some tips for working with CSV files in vim:
http://vim.wikia.com/wiki/Working_with_CSV_files
I'm not sure if there's a way to display it in columns, without commas, though the tips in that link allow vim to traverse and manipulate CSV very easily.
I use #chrisbra's plugin,
" depending on your package manager
dein#add('chrisbra/csv.vim')
and I add a quick command on page load;
could be risky on large records.
autocmd BufRead *.csv :%ArrangeColumn

Resources