I have a CSV file filename.csv with the contents.
,"Private"Range availability1 (%)","Public"Range availability2 (%)"
"Country""Color","2007-2013""Number Color 1","2007-2013""Number Color 2"
"Afghanistan""Red","94"99.0","81.1"
"Bahamas","42.9","43"5.2"
"Brazil""Orange","76"12.7"9","0.0"
"Burundi""Yellow","58"33.3"9","46"1.7"2"
"China""Green","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3"9","21"76.2"
"Ecuador""Blue","71"87.1"6","41"97.7"2"
"Haiti""Purple","54"86.3"8","17"55.6"5"
I am trying to sort the file numerically by values from the second column. However, the first two rows of the file are the titles, and I would like to omit them. My command is below, but it outputs the original file without the first two rows, but also without sorting by the second column.
awk -F ',' '(NR>2)’ filename.csv | sort -t',' -k2 -n
Desired output:
"China","13.3","15.5"
"Congo","31.3","21.2"
"Bahamas","42.9","43.2"
"Haiti","54.3","17.6"
"Burundi","58.3","46.7"
"Ecuador","71.1","41.7"
"Brazil","76.7","0.0"
"Colombia","90.7","86.7"
"Afghanistan","94.0","81.1"
Any help is appreciated :) Thanks!