Help with removing rows from a csv file based on entry in a particular column

GavinC

Registered
Hi,

I wonder if anyone can answer what is probably a relatively simple thing...

I have a csv file with tens of thousands of rows and about 15 columns. For the sake of simplicity though lets pretend it looks like this....

"blah","blah","blah","rs134582","blah"
"blah","blah","blah","","blah"
"blah","blah","blah","rs76589","blah"
"blah","blah","blah","rs12749392","blah"
"blah","blah","blah","rs1234","blah"
"blah","blah","blah","","blah"

I need to remove those rows that have a blank in the 4th column only so that I am left with a file that would look like this...

"blah","blah","blah","rs134582","blah"
"blah","blah","blah","rs76589","blah"
"blah","blah","blah","rs12749392","blah"
"blah","blah","blah","rs1234","blah"

I thought maybe I could use awk to do this, but I can't seem to work it out. Just to clarify, in the real file there may be blanks in other columns, but I only want it to remove the rows with blanks in my one particular column of interest.

Can anybody help me?
 
Looks like you could simply remove the desired columns with Google docs or Open office.
http://www.ehow.com/how_5667925_remove-csv-columns.html

Depending on the file and where it is used, there may be additional limitations.
E.g. if the file is to be used with something that requires a valid checksum (e.g. Capacity Planner or its related plugin for vCenter), editing the file manually will usually create problems.
Or if the file is used by Address Book, and the default template is not modified, all new records will get the "" for the data they don't have on the 4th column.

You could also cut it or experiment with some perl to move it.
http://stackoverflow.com/questions/...r-out-specific-column-from-a-csv-file-in-perl
 
Back
Top