[Tutor] help on dic creation
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Nov 6 15:01:43 CET 2012
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]
> ValTwo=linelist[6]
> ValThree=boolean(linelist[7])
> D={Key:(ValOne, ValTwo, ValThree, ValCity,ValState)}
Put the line above inside the for loop :)
> return D
> print fieldict("DOT500.txt")
>
--
Cheers.
Mark Lawrence.
More information about the Tutor
mailing list