Skip to main content
deleted 395 characters in body
Source Link
c200402
  • 11
  • 1
  • 5

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!

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

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!

I have a CSV file filename.csv with the contents.

,"Range 1 (%)","Range 2 (%)"
"Color","Number Color 1","Number Color 2"
"Red","99.0","5.2"
"Orange","12.9","0.0"
"Yellow","33.9","1.2"
"Green","13.9","76.2"
"Blue","87.6","97.2"
"Purple","86.8","55.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

Any help is appreciated :) Thanks!

added 84 characters in body
Source Link
c200402
  • 11
  • 1
  • 5

How Command to sortSort by the second column and omit theOmit first two rows command?

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

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 doesn't executeoutputs 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!

How to sort by the second column and omit the first two rows command?

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

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 doesn't execute.

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!

Command to Sort by second column and Omit first two rows

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

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!

added 473 characters in body
Source Link
c200402
  • 11
  • 1
  • 5

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

I am trying to sort a CSVthe file numerically by values from the second column. However, the first two rows of the file are the titles. How do, and I would like to omit/ignore the first two lines (two headers)? Below is my them. My command is below, but it doesn't execute.

sortawk -uF -k2',' '(NR>2)’ filename.csv | tailsort -n +2 |t',' head-k2 -1n

Below is part of the CSV file.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!

ColorCostUnits
0-10000-100
Red4394
Red2935
Blue9971
Yellow617

I am trying to sort a CSV file by values from the second column. However, the first two rows of the file are the titles. How do I omit/ignore the first two lines (two headers)? Below is my command, but it doesn't execute.

sort -u -k2 filename.csv | tail -n +2 | head -1

Below is part of the CSV file. Any help is appreciated :) Thanks!

ColorCostUnits
0-10000-100
Red4394
Red2935
Blue9971
Yellow617

I have a CSV file filename.csv with the contents.

,"Private availability (%)","Public availability (%)"
"Country","2007-2013","2007-2013"
"Afghanistan","94.0","81.1"
"Bahamas","42.9","43.2"
"Brazil","76.7","0.0"
"Burundi","58.3","46.7"
"China","13.3","15.5"
"Colombia","90.7","86.7"
"Congo","31.3","21.2"
"Ecuador","71.1","41.7"
"Haiti","54.3","17.6"

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 doesn't execute.

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!

Source Link
c200402
  • 11
  • 1
  • 5
Loading