I've got perfmon outputting to a csv and I need to delete any repeated columns, e.g.
COL1, Col2, Col3, COL1, Col4, Col5
When columns repeat it's almost always the same column but it doesn't happen every time. What I've got so far are a couple of manual steps:
When the column count is greater than it should be I output all of the column headers on single lines:
head -n1 < output.csv|sed 's/,/\n/g'
Then, when I know which column numbers are guilty, I delete manually, e.g.:
cut -d"," --complement -f5,11 < output.csv > output2.csv
If somebody can point me in the right direction I'd be grateful!
Updated to give rough example of output.csv contents, should be familiar to anyone who's used perfmon:
"COLUMN1","Column2","Column3","COLUMN1","Column4"
"1","1","1","1","1"
"a","b","c","a","d"
"x","dd","ffd","x","ef"
I need to delete the repeated COLUMN1 (4th col)
Just to be clear, I'm trying to think of a way of automatically going into output.csv and deleting repeated columns without having to tell it which columns to delete a la my manual method above. Thanks!
"1","1","1","1","1"? Leave just one value? Should the commas be kept or not? Your problem is quite underspecified.