Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hi Guys, I have this data in text file
------|----------|--------|-------------------------|--------| S.No | TimeStamp| UE-Name| Test-Config | UL/DL | ------|----------|--------|-------------------------|--------| 1 | 18:24:38 | -NA- | Sanity_001_0001_10_00 | System | ------|----------|--------|-------------------------|--------| 2 | 18:31:34 | ueh1 | Sanity_002_0002_00_11 | UL | ------|----------|--------|-------------------------|--------| 3 | 18:23:48 | ueh1 | Sanity_003_0003_06_09 | UL | ------|----------|--------|-------------------------|--------| 3 | 18:23:48 | ueh1 | Sanity_003_0003_06_09 | DL | ------|----------|--------|-------------------------|--------| 4 | 18:38:30 | ueh1 | Sanity_004_0004_24_00 | DL | ------|----------|--------|-------------------------|--------| 5 | -NA- | -NA- | Sanity_001_0001_10_00 | System | ------|----------|--------|-------------------------|--------| 6 | 18:31:34 | ueh2 | Sanity_002_0002_00_11 | UL | ------|----------|--------|-------------------------|--------| 7 | 18:23:49 | ueh2 | Sanity_003_0003_06_09 | UL | ------|----------|--------|-------------------------|--------| 7 | 18:23:48 | ueh2 | Sanity_003_0003_06_09 | DL | ------|----------|--------|-------------------------|--------| 8 | 18:38:30 | ueh2 | Sanity_004_0004_24_00 | DL | ------|----------|--------|-------------------------|--------|
i have tried this thing all text file data is in @executioncontents array
my %data; foreach (@executioncontents) { my $currLine = $_; my @Report = split(/\|/, $currLine); my $arraysize = $#Report; if ($arraysize == 11) { foreach (@Report) { if ($_ =~ m/--/) { } else { my $timestamp = $Report[1]; my $testcase = $Report[4]; my $uename = $Report[2]; my $keyvalues =$timestamp."_".$uename."_".$testcas +e; $data{$keyvalues}{serial_number} = $Report[0]; $data{$keyvalues}{time_Stamp} = $Report[1]; $data{$keyvalues}{ue_name} = $Report[2]; $data{$keyvalues}{test_config} = $Report[3]; $data{$keyvalues}{ul_dl} = $Report[4]; $data{$keyvalues}{status} = $Report[5]; $data{$keyvalues}{jiter} = $Report[6]; $data{$keyvalues}{throughput} = $Report[7]; $data{$keyvalues}{lost} = $Report[8]; $data{$keyvalues}{bandwidth} = $Report[9]; $data{$keyvalues}{duration} = $Report[10]; $data{$keyvalues}{failed_reason} = $Report[11]; } } } } readhash(\%data); sub readhash { my $reff = shift; my %xyz = %$reff; my $workbook = Excel::Writer::XLSX->new( "Data"); my $worksheet = $workbook->add_worksheet("data"); my @array; my $rows = 14; foreach my $key (sort %xyz) { if ($xyz{$key}{ue_name} =~ m/ue|NA/) { push(@array, $xyz{$key}{ue_name}); $worksheet->write($rows, 0, $xyz{$key}{serial_number}); $worksheet->write($rows, 1, $xyz{$key}{time_Stamp}); $worksheet->write($rows, 2, $xyz{$key}{ue_name}); $worksheet->write($rows, 3, $xyz{$key}{test_config}); $worksheet->write($rows, 4, $xyz{$key}{ul_dl}); $worksheet->write($rows, 5, $xyz{$key}{status}); $worksheet->write($rows, 6, $xyz{$key}{jiter}); $worksheet->write($rows, 7, $xyz{$key}{throughput}); $worksheet->write($rows, 8, $xyz{$key}{lost}); $worksheet->write($rows, 9, $xyz{$key}{bandwidth}); $worksheet->write($rows, 10, $xyz{$key}{duration}); $worksheet->write($rows, 11, $xyz{$key}{failed_reason}); $rows++; } } }

It parse the data in xlsx file in differnt manner from the way it is in acutal file

5 -NA- -NA- Sanity_001_0001_10_00 Syst +em 3 18:23:48 ueh1 Sanity_003_0003_06_09 DL + 3 18:23:48 ueh1 Sanity_003_0003_06_09 UL + 7 18:23:48 ueh2 Sanity_003_0003_06_09 DL + 7 18:23:49 ueh2 Sanity_003_0003_06_09 UL + 1 18:24:38 -NA- Sanity_001_0001_10_00 Syst +em 2 18:31:34 ueh1 Sanity_002_0002_00_11 UL + 6 18:31:34 ueh2 Sanity_002_0002_00_11 UL + 4 18:38:30 ueh1 Sanity_004_0004_24_00 DL + 8 18:38:30 ueh2 Sanity_004_0004_24_00 DL + S.No TimeStamp UE-Name Test-Config UL/D +L

Please anyone can help me to parse the data in xlsx file the way it is in actal file.

Thanks in advance

In reply to Re^2: Parsing Data in xlsx file by Rahul Gupta
in thread Parsing Data in xlsx file by Rahul Gupta

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (9)
    As of 2014-09-16 07:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite cookbook is:










      Results (157 votes), past polls