MSC_name,chunum,date,count
MSCBCR1,1,01-JUL-03,168
MSCBCR1,1,02-JUL-03,163
MSCBCR1,1,03-JUL-03,166
MSCBCR1,1,04-JUL-03,159
MSCBCR1,1,05-JUL-03,161
MSCBCR1,1,06-JUL-03,161
MSCBCR1,1,07-JUL-03,159
MSCBCR1,1,08-JUL-03,158
MSCBCR1,1,09-JUL-03,160
MSCBCR1,1,10-JUL-03,161
MSCBCR1,1,11-JUL-03,164
MSCBCR1,1,12-JUL-03,166
MSCBCR1,1,13-JUL-03,165
MSCBCR1,1,14-JUL-03,160
MSCBCR1,1,15-JUL-03,163
MSCBCR1,1,16-JUL-03,170
MSCBCR1,1,17-JUL-03,162
MSCBCR1,1,18-JUL-03,161
MSCBCR1,1,19-JUL-03,165
MSCBCR1,1,20-JUL-03,162
MSCBCR1,1,21-JUL-03,155
MSCBCR1,1,22-JUL-03,160
MSCBCR1,1,23-JUL-03,161
MSCBCR1,1,24-JUL-03,159
MSCBCR1,1,25-JUL-03,160
MSCBCR1,1,26-JUL-03,161
MSCBCR1,1,27-JUL-03,170
MSCBCR1,1,28-JUL-03,170
MSCBCR1,1,29-JUL-03,170
MSCBCR1,1,30-JUL-03,170
MSCBCR2,1,01-JUL-03,168
MSCBCR2,1,02-JUL-03,163
MSCBCR2,1,03-JUL-03,166
MSCBCR2,1,04-JUL-03,159
MSCBCR2,1,05-JUL-03,161
MSCBCR2,1,06-JUL-03,161
MSCBCR2,1,07-JUL-03,159
MSCBCR2,1,08-JUL-03,158
MSCBCR2,1,09-JUL-03,160
MSCBCR2,1,10-JUL-03,161
MSCBCR2,1,11-JUL-03,164
MSCBCR2,1,12-JUL-03,166
MSCBCR2,1,13-JUL-03,165
MSCBCR2,1,14-JUL-03,160
MSCBCR2,1,15-JUL-03,163
MSCBCR2,1,16-JUL-03,170
MSCBCR2,1,17-JUL-03,162
MSCBCR2,1,18-JUL-03,161
MSCBCR2,1,19-JUL-03,165
MSCBCR2,1,20-JUL-03,162
MSCBCR2,1,21-JUL-03,155
MSCBCR2,1,22-JUL-03,160
MSCBCR2,1,23-JUL-03,161
MSCBCR2,1,24-JUL-03,159
MSCBCR2,1,25-JUL-03,160
MSCBCR2,1,26-JUL-03,161
MSCBCR2,1,27-JUL-03,170
MSCBCR2,1,28-JUL-03,170
MSCBCR2,1,29-JUL-03,170
MSCBCR2,1,30-JUL-03,170
The output that will be needed will be:
MSC_name,count_per_date1...end_date(e.g. 30-JUL-03)
total_cf_produced,total_per_date...total_per_date(e.g. end_date 30-JUL-03
I've been trying out this code but can't get it to work:
#!c:/perl/bin/perl open (INFILE,"c:/playgnd/sql_result_cf.txt") || die("Could not open fi +le!"); while( <INFILE> ) { next if $. == 1; # skip first line chomp; my %F; @F{qw(msc_name chunum date count_per_date)} = split /\s*,\s*/; $Data{$F{date}} = { } unless exists $Data{$F{msc_name}}; $Data{$F{date}}->{$F{msc_name}} = [('')x5] unless ref( $Data{$F{date}}->{$F{msc_name}}); ${$Data{$F{date}}->{$F{msc_name}}}[$F{hour}] = $F{count_per_hour}; } foreach my $date (keys %Data) { foreach my $msc_name (keys %{$Data{$date}}) { print join(",", $date, $msc_name, @{$Data{$date}->{$msc_name}}), +"\n" ; } } close(INFILE);
Edit: Added <code> tags, larsen.
In reply to Formating Text file by redskie007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |