Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Accumulating Column Total From a CSV for a Common Key Value

by agianni (Hermit)
on Aug 30, 2007 at 13:06 UTC ( #636068=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Accumulating Column Total From a CSV for a Common Key Value
in thread Accumulating Column Total From a CSV for a Common Key Value

Sorry, that was just off the top of my head, not tested. Hopefully you've figured this out on your own already, but just replace $total{$appl} with $total{$server}->{$date}->{$appl} and that should give you the values in the pct column you're looking for. If you didn't figure that out on your own, you should really read up on perl data structures. perldsc is a good place to start.

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'


Comment on Re^3: Accumulating Column Total From a CSV for a Common Key Value
Select or Download Code
Re^4: Accumulating Column Total From a CSV for a Common Key Value
by GeneV1 (Initiate) on Sep 06, 2007 at 13:10 UTC

    agianni, this worked marvelously and most importantly I picked up a few pointers on perl use. It now turns out that I have in my input multiple Servers (the 1st field) in addition to multiple Login ID's (the 3rd field) per Application (the 4th field). I am able to accumulate the Percent of Totals by Application with your code.

    Sample output from your code would look as follows:

    xsd00501,05/2007,"Shared Production (PRD,0.2% xsd00501,05/2007,OMX (old MBX userid),0.9% xsd00501,05/2007,PTI - Private Client Services,0.0% xsd00501,05/2007,SSG-IPM,3.1% xsd00501,05/2007,SSG-PMD-Omegamon,0.6% xsd00501,05/2007,SSG-RAC-Maestro ,45.7% xsd00501,05/2007,STW - Stock Transfer Workstation,1.1% xsd00506,05/2007,ADR,0.4% xsd00506,05/2007,OBR Production,0.1% xsd00506,05/2007,RAC/AMOS/DSO,43.3% xsd00506,05/2007,SPS - Inform,1.2% xsd00506,05/2007,SPS Production (also IRD till 7/03),11.7% xsd00506,05/2007,SSG-IPM,2.6% xsd00506,05/2007,SSG-PMD-Omegamon,0.6% xsd00506,05/2007,SSG-RAC-Maestro ,17.0% xsd00544,05/2007,"DB2DARI ""stored procedures"" prod",2.1% xsd00544,05/2007,BMW,0.0% xsd00544,05/2007,CTI Production ,21.7% xsd00544,05/2007,CTI,13.1% xsd00544,05/2007,Merva,0.0% xsd00544,05/2007,OMS,13.7% xsd00544,05/2007,PTI - Private Client Services,0.0% xsd00544,05/2007,SSG-IPM,4.5% xsd00544,05/2007,SSG-PMD-Omegamon,0.1% xsd00544,05/2007,SSG-RAC-Maestro ,2.6% xsd00722,05/2007,SSG-PMD-Omegamon,1.9% xsd00722,05/2007,SSG-RAC-Maestro ,23.1%

    In addition, after the last Server entry, I need to output a TOTAL line with the Total Percentage for all Applications for a particular Server and Date. For the server/date combination (xsd00501,05/2007) above, a line after the last line with xsd00501,05/2007, would be printed totalling the percentages, as follows:

    xsd00501,05/2007,TOTAL,51.6%

    Up to this point in my limited perl programming experiences,I have been unable to grasp how to determine when a particular variable changes its value in the input and when this happens doing a particular task.

    Any assistance would be greatly appreciated.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://636068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-12-28 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls