Reading in a file

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 14 03:13:07 EDT 2010


En Mon, 12 Apr 2010 15:31:50 -0300, Maggie <la.foma at gmail.com> escribió:

> i have a basic script i need to implement. i need below code to read
> in a file and perform operation is it designed to do:
>
> #!/usr/bin/python
>
> import sys
>
> feed = sys.stdin.readlines()
>
> for temp in feed:
>   line = temp.split()
>   if len(line) == 3:
>      if (line[0] == "xmax" or line[0] == "xmin"):
>        time = line[2]
>        print str(line[0]) + " " + str(line[1]) + " " +
> str(float(time)*2/3)
>      else:
>        print temp
>   else:
>      print temp
>
> i appreciate your help in advance..

You forgot to tell us what's wrong with it.

-- 
Gabriel Genellina




More information about the Python-list mailing list