read file to a dictionary

Larry Bates larry.bates at websafe.com
Wed May 23 19:47:53 EDT 2007


rohit wrote:
> i want to implement a dictionary in python
> the query is :
> without explicitly doing the following steps
> 1. reading from file to list
> 2. processing list to dictionary
>  is there a module or a built in function that helps me "read" a file
> directly into a dictionary
> or any module that implements the above 2 steps
> 
> thanks
> rohit
> 
csv module will read individual lines into a dictionary with keys
being the field names.  You can then do something with that.  It
is unclear what the keys, values are for your dictionary when read
from a file.  More info will be required to help more.

-Larry



More information about the Python-list mailing list