Re: Reading a file into a data structure....

2011-10-16 Thread Ian Kelly
On Sat, Oct 15, 2011 at 8:18 PM, MrPink wrote: > I did not understand what a tuple was. > So it was very hard for me to understand what a namedtuple was and > follow the code. > Then I looked up the word at dictionary.com and got this: > http://dictionary.reference.com/browse/tuple > > tuple:  com

Re: Reading a file into a data structure....

2011-10-15 Thread MrPink
I did not understand what a tuple was. So it was very hard for me to understand what a namedtuple was and follow the code. Then I looked up the word at dictionary.com and got this: http://dictionary.reference.com/browse/tuple tuple: computing a row of values in a relational database Now I under

Re: Reading a file into a data structure....

2011-10-15 Thread Troy S
Chris, Thanks for the help. I am using the powerball numbers from this text file downloaded from the site. http://www.powerball.com/powerball/winnums-text.txt The first row is the header/fieldnames and the file starts off like this: Draw Date WB1 WB2 WB3 WB4 WB5 PB PP 10/12/2011 43 10 12 23

Re: Reading a file into a data structure....

2011-10-14 Thread Chris Rebert
On Fri, Oct 14, 2011 at 7:59 PM, MrPink wrote: > This is what I have been able to accomplish: > > def isInt(s): >    try: >        i = int(s) >        return True >    except ValueError: >        return False > > f = open("powerball.txt", "r") > lines = f.readlines() > f.close() > > dDrawings = {}

Re: Reading a file into a data structure....

2011-10-14 Thread Chris Angelico
On Sat, Oct 15, 2011 at 1:59 PM, MrPink wrote: > def isInt(s): >    try: >        i = int(s) >        return True >    except ValueError: >        return False > > f = open("powerball.txt", "r") > lines = f.readlines() > f.close() > > dDrawings = {} > for line in lines: >    if isInt(line[0]): >  

Re: Reading a file into a data structure....

2011-10-14 Thread MrPink
This is what I have been able to accomplish: def isInt(s): try: i = int(s) return True except ValueError: return False f = open("powerball.txt", "r") lines = f.readlines() f.close() dDrawings = {} for line in lines: if isInt(line[0]): t = line.split()

Re: Reading a file into a data structure....

2011-10-13 Thread Jon Clements
On Oct 13, 10:59 pm, MrPink wrote: > This is a continuing to a post I made in > August:http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > I got some free time to work with Python again and have some followup > questions. > > For example, I have a list in a text file like

Re: Reading a file into a data structure....

2011-10-13 Thread Ian Kelly
On Thu, Oct 13, 2011 at 3:59 PM, MrPink wrote: > This is a continuing to a post I made in August: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/b072cfadf998deae/ce6d4d09911e4107?lnk=gst&q=MrPink#ce6d4d09911e4107 > > I got some free time to work with Python again and have s

Reading a file into a data structure....

2011-10-13 Thread MrPink
This is a continuing to a post I made in August: http://groups.google.com/group/comp.lang.python/browse_thread/thread/b072cfadf998deae/ce6d4d09911e4107?lnk=gst&q=MrPink#ce6d4d09911e4107 I got some free time to work with Python again and have some followup questions. For example, I have a list in