[Tutor] Data chart

Adam Jensen hanzer at riseup.net
Fri Nov 21 01:23:49 CET 2014


import fileinput

def parseLine(a):
    x = a.split('/')
    b = x[1].split(':')
    c = b[0].split('.')
    y = c[0]
    z = int(b[2])
    return x[0], y, z
    
print('{:>4}{:>10}{:>8}{:>8}'.format('','canofica','lnvd','msd'))

data = [0, 0, 0]
prevDate = "None"

for line in fileinput.input():    
    thisDate, name, value = parseLine(line)
    if (thisDate != prevDate): 
        if (prevDate != "None"):
            print('{:>4}{:>10}{:>8}{:>8}'.format(prevDate,
                  data[0],data[1],data[2]))
        prevDate = thisDate    
    if name == "canofica":
        data[0] = value
    elif name == "lnvd":
        data[1] = value
    elif name == "msd":
        data[2] = value
print('{:>4}{:>10}{:>8}{:>8}'.format(prevDate,data[0],data[1],data[2]))    
fileinput.close()

From: Tutor [mailto:tutor-bounces+hanzer=riseup.net at python.org] On Behalf Of Mamy Rivo DIANZINGA
Sent: Wednesday, November 19, 2014 11:42 AM
To: tutor at python.org
Subject: [Tutor] Data chart

Good morning Sir. Excuse me to bother you but i was wondering if you can help me, please Sir. 
I am looking for a script (in python or fortran...) which can turn the data from Iter.dat, that i joined for you, into a chart like this:

           canofica   lnvd    msd
10_2         ...      ....    ...
 9_1         ...      ....    ...


I hope i do not exagerate, and i will be very grateful to you if you can help me, for any script in python or fortran. Thank in advance.
Best regards.



More information about the Tutor mailing list