[Tutor] How to calculate high value from multiple lines for each column

Fosiul Alam fosiul at gmail.com
Sat Feb 27 10:46:57 EST 2016


Hi Alan
Thanks for the help.yes now i can see how it working, i am just stick in
small things
so this is what i have done ,

a) Can I combile 2 forloop into one ?
b) How can remove first value from for loop - step a ?


        for key in values:
                print "svtm-%s ,%s" % (key, values[key][0])

        for key in values:
                print "iostat-%s ,%s" % (key, values[key][1])
        #print data
        print "Remove First value", values['dm-30'][0].pop(0)
        print "SVTM DM30: ", max(values['dm-30'][0])
        print "Remove First VAlue for", values['dm-30'][1].pop(0)
        print "IOSTAT DM-30",max(values['dm-30'][1])


output

svtm-dm-30 ,[18.27, 2.0, 0.40000000000000002]
svtm-dm-31 ,[18.280000000000001, 3.0, 0.69999999999999996]
iostat-dm-30 ,[6.3600000000000003, 1.0, 0.5]
iostat-dm-31 ,[6.3700000000000001, 1.5, 0.59999999999999998]
Remove First value 18.27
SVTM DM30:  2.0
Remove First VAlue for 6.36
IOSTAT DM-30 1.0

Thanks for the help.


On Fri, Feb 26, 2016 at 8:12 AM, Alan Gauld <alan.gauld at btinternet.com>
wrote:

> On 26/02/16 02:36, Fosiul Alam wrote:
> > 1) the final data out put only has  one values  dm-31 but dm-30 is
> > missing.
>
> That's because data is only ever the last iteration of the loop.
> Your output is in values not data.
> Try printing values at the end of the loop.
>
> > 2) I need to assoicated values with dm name example dm-30 and dm-31 as
> > final result .
>
> You are already doing that.
> Its working as expected.
>
> > ['dm-30', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00',
> > '0.00', '0.00', '0.40', '0.50']
> > [[18.27, 2.0], [6.3600000000000003, 1.0]]
> > ===
> > ['dm-31', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00',
> > '0.00', '0.00', '0.70', '0.60']
> > [[18.280000000000001, 3.0], [6.3700000000000001, 1.5]]
>
> Note that the data lines above reflect the correct results for both dm30
> and dm31.
>
> So values is storing both sets of data correctly.
>
> After the loop try:
>
> print "DM30: ", values['dm-30']
> print "DM31:", values['dm-31']
>
>
> HTH,
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>


-- 
Regards
Fosiul Alam


More information about the Tutor mailing list