Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Monks,
I'm trying to print the coverage table. I was trying to use the Data::Table module:
my @table_header = ("Package", "Coverage", "Line", "Method", "Branch") +; my @data_table; foreach my $package (sort(keys(%{$result}))) { my $instruction_package_missed = $result->{$package}{$HEADER_INST +RUCTION_MISSED}; my $instruction_package_covered = $result->{$package}{$HEADER_INST +RUCTION_COVERED}; my $branch_package_missed = $result->{$package}{$HEADER_BRAN +CH_MISSED}; my $branch_package_covered = $result->{$package}{$HEADER_BRAN +CH_COVERED}; my $line_package_missed = $result->{$package}{$HEADER_LINE +_MISSED}; my $line_package_covered = $result->{$package}{$HEADER_LINE +_COVERED}; my $method_package_missed = $result->{$package}{$HEADER_METH +OD_MISSED}; my $method_package_covered = $result->{$package}{$HEADER_METH +OD_COVERED}; my $instructions_package_total = $instruction_package_missed + $in +struction_package_covered; my $branchs_package_total = $branch_package_missed + $branch_ +package_covered; my $lines_package_total = $line_package_missed + $line_pack +age_covered; my $methods_package_total = $method_package_missed + $method_ +package_covered; my $instruction_package_percentage = calculate_percentage($instruc +tion_package_covered,$instructions_package_total); my $branch_package_percentage = calculate_percentage($branch_ +package_covered,$branchs_package_total); my $line_package_percentage = calculate_percentage($line_pa +ckage_covered,$lines_package_total); my $method_package_percentage = calculate_percentage($method_ +package_covered,$methods_package_total); my $instruction_package_summary = "$instruction_package_percentage +\%"; my $branch_package_summary = "$branch_package_percentage\% ($ +branch_package_covered/$branchs_package_total)"; my $line_package_summary = "$line_package_percentage\% ($li +ne_package_covered/$lines_package_total)"; my $method_package_summary = "$method_package_percentage\% ($ +method_package_covered/$methods_package_total)"; my @coverage_line = ($package, $instruction_package_summary, $line +_package_summary, $method_package_summary, $branch_package_summary); push(@data_table,\@coverage_line); } my $table = Data::Table->new(\@data_table, \@table_header, 0); print $table->tsv."\n";
But it print it:
Package Coverage Line Method Branch com.gandu.base.alltests 90% 91% (20/22) 50% (1/2) 0 +% (0/0) com.gandu.base.commons 47% 43% (579/1336) 34% (73/213) 4 +1% (111/270) com.gandu.base.commons.status 27% 27% (103/388) 46% (25/5 +4) 8% (5/60) com.gandu.base.commons.test 94% 84% (62/74) 85% (11/13) 1 +00% (6/6) com.gandu.base.commons.validchecker 90% 90% (9/10) 50% + (1/2) 0% (0/0) com.gandu.base.commons.validchecker.arghandler 12% 8% (115/140 +4) 8% (8/99) 0% (0/350) com.gandu.base.commons.validchecker.centralarea 26% 37% (111/29 +7) 65% (17/26) 56% (47/84) com.gandu.base.commons.validchecker.testtag 85% 82% (613/74 +8) 82% (93/114) 53% (90/170) com.gandu.base.consoleindependentcommons 91% 91% (79/87) 8 +2% (14/17) 90% (18/20) com.gandu.base.disk 80% 79% (70/89) 76% (16/21) 75% (27/3 +6) com.gandu.base.disk.test 2% 3% (3/98) 7% (1/14) 0 +% (0/0) com.gandu.base.flow 39% 37% (479/1281) 41% (131/321) 6% (21/33 +6) com.gandu.base.flow.parser 31% 34% (468/1363) 34% (48/141) 1 +5% (51/348) com.gandu.base.helpcontent 0% 0% (0/6) 0% (0/4) 0 +% (0/0) com.gandu.base.datafeeder 0% 0% (0/144) 0% (0/23) + 0% (0/66) com.gandu.base.datafeeder.test 3% 4% (3/82) 8% (1/12) + 0% (0/20) com.gandu.base.preferencefiles 62% 55% (505/915) 52% (15/2 +9) 21% (42/204) com.gandu.base.preferences 50% 43% (1139/2620) 28% (138/500) 6 +% (38/688) com.gandu.base.report 19% 22% (439/1954) 61% (46/76) 4 +7% (105/224) com.gandu.base.report.emailreport 91% 88% (244/278) 93% (26/2 +8) 67% (28/42) com.gandu.base.report.test 86% 86% (6/7) 50% (1/2) 0 +% (0/0) com.gandu.base.managerexec 28% 26% (1101/4209) 43% (90/208) 34 +% (200/593) com.gandu.base.managerexec.runmanager 18% 18% (344/1913) 23 +% (46/200) 19% (122/638) com.gandu.base.managerexec.rununitexecutor 15% 18% (907/5149) 40 +% (115/291) 6% (61/1062) com.gandu.base.testmanager 95% 89% (117/131) 78% (21/27) 8 +2% (28/34) com.gandu.base.testmanager.housekeeping 72% 69% (1044/1513) 6 +8% (116/171) 50% (130/260) com.gandu.base.util 10% 11% (48/450) 13% (11/82) 12% (13/1 +07) com.gandu.base.util.test 81% 80% (4/5) 50% (1/2) 0 +% (0/0)
I'm trying to print the table aligned so each column will be seperated. I could not find a method in Data::Table but I may missed it. I also noticed that Text::Table and Text::Table::Tiny, can be used but unfortunately those modules are not installed by IT in the central area so I prefer to use an installed module or implementation of this idea. What would be a good way to solve it?
Edit: I'm looking to a similar solution to the output of Python's pandas.

In reply to Align columns in a table by ovedpo15

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-29 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found