in reply to Need to sort comma delimited, double quoted file
The are multiple examples freely available to do exactly that. One of the tools that enables you to do this from the command-line is xlscat as available in the Spreadsheet::Read distribution. That will (also) use Text::CSV_XS to parse your CSV data
$ xlscat --sort=31n,1n,2n file.csv
As your CSV however is not valid CSV (see ,"Max Smart Super, Speciality Hospital "O"", where the double quotes inside the field are not escaped), you might need to roll your own script.
A really quick braindump that works on the snippet you showed is:
use 5.18.2; use warnings; use Data::Peek; use Text::CSV_XS qw( csv ); my $aoa = csv (in => "test.csv", escape => undef, allow_loose_quotes = +> 1); csv (in => [ sort { $a->[30] <=> $b->[30] || $a->[0] <=> $b->[0] || $a->[1] <=> $b->[1] } @$aoa ]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need to sort comma delimited, double quoted file
by CSharma (Sexton) on Jul 26, 2017 at 06:55 UTC | |
by Tux (Canon) on Jul 26, 2017 at 15:49 UTC | |
by CSharma (Sexton) on Jul 28, 2017 at 04:19 UTC | |
by CSharma (Sexton) on Jul 27, 2017 at 08:13 UTC | |
by hippo (Archbishop) on Jul 27, 2017 at 08:42 UTC |