creating a subnested lists from a comma seperated string read from a file

Mark McEahern marklists at mceahern.com
Thu Aug 22 15:31:50 EDT 2002


[Danathar]
> Thanks for all of the answers, after some more digging I found
>
> os.getlogin - its seems to be specific to Python 2.2...

Minor comment:  If you change the subject people who sort by subject to
follow a thread (perhaps only those who are braindead like me do that, but
anyway), folks really have no idea what you're referring to.

> How can I take each string element in my LIST variable with my comma
> seperated fields and turn them into a subnested lists with each comma
> seperated field as individual elements....

Sample:

f = file(filename)
lines = f.readlines()
f.close()

for line in lines:
  fields = line.split(",")
  for field in fields:
    etc.

Ain't Python just purty?

// mark

-





More information about the Python-list mailing list