Extract certain column from CSV files
9,475
Solution 1
To extract from the 3rd column for example, you can do:
cut -d',' -f3 OCS_mobfwref-oam_d01_2014080*
This only works if there are no un-escaped comma's!
If you want to remove the headers, do:
sed 1d OCS_mobfwref-oam_d01_2014080* | OCS_mobfwref-oam_d01_2014080*
Solution 2
the same in awk, with a head in first 2 lines, extracting the third field, assuming filed separator is ',' (comma).
awk -F, 'NR>2 { print $3 ; }' *.csv
Related videos on Youtube
Author by
Breevie
Updated on September 18, 2022Comments
-
Breevie over 1 year
I have a directory with a group of CSV files. All files have the same column headers. I need to extract values in a certain column from all files.
The common part in files names is
OCS_mobfwref-oam_d01_2014080*
-
jimm-cl almost 10 yearsProvide a sample of the data in the files, to see what the delimiter is, the number of columns, etc... Also, what have you tried so far?
-
terdon almost 10 yearsHi and welcome to the site. Next time, please give us an example of your input and the output you want. It makes it much easier to understand what you need.
-
-
Breevie almost 10 yearsremoving headers isn't working