Is there a way to sort the csv file based on the 1st column using some shell command?
I have this huge file with over 150k lines, so I can do it in excel :( is there an alternative way?
sort -k1 -n -t, filename should do the trick.
sort -k1 -n -t, filename
-k1 sorted by column 1.
-k1
-n sorted numerically instead of lexicographical (so that "11" will not be earlier than "2,3 ...").
-n
-t, sets the delimiter (separates the values ββin your file) to, since your file is separated by a comma.
-t,
I do not know why the above solution did not work in my case.
15,5 17,2 18,6 19,4 8,25 8,90 9,47 9,49 10,67 10,90 13,96 159,9
however, this team solved my problem.
sort -t "," -k1n, 1 fileName
csvsort
Install csvkit if it is not already installed.
csvkit
brew install csvkit
Sort CSV by first column.
csvsort -c 1 original.csv > sorted.csv