0

I need to sort a big csv file .So,using

sort

command will be quite good.

But, I am facing an issue that delimiter ',' is also present in the data . So, sorting on fields with ',' works unexpectedly .

The file contains data like

Ahmedabad ,"7,Olive residency ", 380058
Gandhinagar,"85,Kabir villa",38048
Surat ,Binory Bunglows,589635

And I am using sort command like

 sort --field-separator=',' -s -k 3,3  bigfile.csv 

Which does not give desired output.

Can any one help me with this ?

2
  • You should probably just bite the bullet and use a CSV parser. Commented Apr 18, 2016 at 17:27
  • or reexport the data with a field delilmiter that is not in your data. The <tab> character is often very useful, as it is difficult (but not impossible) for <tab> to be inserted into an on-line data entry form. Good luck. Commented Apr 18, 2016 at 18:47

1 Answer 1

5
sort -k3 -t',' -nr bigfile.csv 
Sign up to request clarification or add additional context in comments.

2 Comments

While this does answer the question, it is very very skimpy. You should add at least a sentence of discussion and maybe a link to the sort(1) documentation.
Also, I recommend indenting your answer four spaces to display it as code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.