simple files

Chad Netzer cnetzer at mail.arc.nasa.gov
Sat May 31 02:56:55 EDT 2003


On Fri, 2003-05-30 at 23:18, Darren Teo wrote:
> Hey how come when i do this it just outputs the last line and not the
> rest of the lines ??? I wish to output each line from file into a
> seperate list .....

Assuming you want tab to be a list of lists, try this:

def readtable(filename):
   tab=[]
   intabfile = open(filename, "r")
   for tablines in intabfile:
      tab.append(string.split(tablines, ":" ,10))
   intabfile.close()
   return tab


-- 

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)






More information about the Python-list mailing list