Re: [Tutor] help on dic creation

2012-11-06 Thread Mark Lawrence
On 06/11/2012 14:16, Dave Angel wrote: On 11/06/2012 09:01 AM, Mark Lawrence wrote: On 31/10/2012 01:01, Brayden Zhao wrote: def fieldict(filename): D={} with open(filename) as FileObject: for lines in FileObject: linelist=lines.split('\t') Key=linelist[0]

Re: [Tutor] help on dic creation

2012-11-06 Thread Dave Angel
On 11/06/2012 09:01 AM, Mark Lawrence wrote: > On 31/10/2012 01:01, Brayden Zhao wrote: > >> def fieldict(filename): >>D={} >>with open(filename) as FileObject: >> for lines in FileObject: >>linelist=lines.split('\t') >>Key=linelist[0] >>ValCity=(linelist[12]).s

Re: [Tutor] help on dic creation

2012-11-06 Thread Mark Lawrence
On 31/10/2012 01:01, Brayden Zhao wrote: def fieldict(filename): D={} with open(filename) as FileObject: for lines in FileObject: linelist=lines.split('\t') Key=linelist[0] ValCity=(linelist[12]).strip() ValState=linelist[13] ValOne=linelist[2]

Re: [Tutor] help on dic creation

2012-11-05 Thread Alan Gauld
On 31/10/12 01:01, Brayden Zhao wrote: Here is my code and I dont know why my code is only reading the 500th line of the file. Thanks for your help! def fieldict(filename): D={} with open(filename) as FileObject: for lines in FileObject: linelist=lines.split('\t') Key=l

Re: [Tutor] help on dic creation

2012-11-05 Thread Brett Ritter
FYI - Gmail's new "compose" feature makes it WAY too easy to miss trimming the quotes. :( On Mon, Nov 5, 2012 at 3:37 PM, Brett Ritter wrote: (way too much) -- Brett Ritter / SwiftOne swift...@swiftone.org ___ Tutor maillist - Tutor@python.org To uns

Re: [Tutor] help on dic creation

2012-11-05 Thread Brett Ritter
> Here is my code and I dont know why my code is only reading the 500th line of > the file. Thanks for your help! Let me offer you some hints: This sounds like only the last line is getting saved into the dict. Yet your loop is clearly going over each line. Ergo, the problem is probably in the

[Tutor] help on dic creation

2012-11-05 Thread Brayden Zhao
hello! I am doing my homework now and I am kinda stuck. Could any of you help me out? Here is the homework problem: fieldict(filename) reads a file in DOT format and returns a dictionary with the DOT CMPLID, converted to an integer, as the key, and a tuple as the corresponding v