pavelpok pavelpok - 1 year ago 140
Linux Question

CSV file cleanup in bash

I have a CSV file delimited with ',' which I'd like to use for further processing in a postgres db but not all lines have the correct number of columns.

I'm looking into a way of deleting all lines which don't have a specified number (15) of delimiters.

I've seen a lot of sed/awk solutions but none that would quite achieve what I need. Thanks!

Answer Source
awk -v FS=',' 'NF==16' <csv>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download