Hello Monks,
I writing extract the content from csv file and create the one more csv files. In the middle of code i have facing one problem. input file contains segment by segment as row wise below i have mentioned
Table=Begin,,,, A, B, C, D, E Value,Value,Value,Value,Value 455,0,0,0,0 135,0,0,0,0 199,0,0,0,0 Table=End,,,, Table=Begin,,,, F, G, H Value,Value,Value 45235,0,0 13524,0,0 Table=End,,,,
output Comes like wise:
A, B, C, D, E, G, H 455,0,0,0,0,45235,0,0 135,0,0,0,0,13524,0,0
my Code is
use strict; use Data::Dumper; open (my $IN, '<', $input_dir.$each_file) or die "cannot open $eac +h_file for writing: $!"; local $/ = "Table="; # Based on the 'RTRV' and split the metric g +roups my @all_metrics= (); while( my $record = <$IN>) { chomp; push (@tables,$record); } open ( my $outFileHandle, '+>', "sample.csv") or die "cannot open $new +File for writing: $!"; my @body=(); my @convert_body= (); foreach my $each_table_grp(@tables) { $each_table_grp =~ m{Value(.+?)Table}gis; push(@body, $1); } my @unique_body = (); foreach my $elem(@body) { next if $seen{ $elem }++; $elem =~ s{,Value}{}gis; push (@unique_body, $elem); } print Dumper(@unique_body); foreach my $body_val(grep /(.+)/, @unique_body) { print $outFileHandle $body_val; }
Please provide me Solution for this code
Thanks
Senthil. V
In reply to Array issues in csv creation by senthil_v
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |