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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.