ukhare has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
My file file.csv is having some columns among which column 1 represents date and time, I am trying to sort it by date and time but it is sorting only based on time. please check and suggest.
#!/usr/bin/perl use strict; my $input_dir = "d://perl//output"; my $output_dir = "d://perl//output"; my $input_file = "$input_dir//file.csv"; my $output_file = "$output_dir//output2_file.csv"; open (OUTPUT, ">>$output_file") or die "Error 016: Error creating $out +put_file \n"; open (INPUT, "<$input_file") or die "Error 001: Error locating file $i +nput_file \n"; my @array =(<INPUT>); #print "Array\n"; #@print join( "\n", @array )."\n\n"; print "Sort Date\n"; print join( "\n", @sortedTime )."\n\n"; print OUTPUT; close (OUTPUT); close (INPUT);
data in file.csv looks like
2016-02-02:00:44,mttsmshub1
2016-02-05:00:39,mttsmshub1
2016-02-03:00:32,tttsmshub1
2016-02-04:00:24,mttsmshub1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Sort date and time inside csv file
by 2teez (Vicar) on Feb 11, 2016 at 09:50 UTC | |
by AnomalousMonk (Archbishop) on Feb 11, 2016 at 17:43 UTC | |
|
Re: Perl Sort date and time inside csv file
by Discipulus (Canon) on Feb 11, 2016 at 08:34 UTC | |
|
Re: Perl Sort date and time inside csv file
by hdb (Monsignor) on Feb 11, 2016 at 07:50 UTC | |
|
Re: Perl Sort date and time inside csv file
by Laurent_R (Canon) on Feb 11, 2016 at 11:15 UTC | |
by ukhare (Novice) on Feb 11, 2016 at 18:49 UTC |