3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by pyTony
0

The general way to create a dictionary is to split the text file records into a key and data, then

if key not in the_dictionary:
    the_dictionary[key] = []     ## this is a list but you can use whatever type you want
the_dictionary[key].append(data)

For additional help you should post some of the input file and how you want to store each record.

Edited by woooee: n/a

0

http://paste.pocoo.org/show/231731/

My problem is listed here... There shouldn't really be a reason (as far as I can see) with memory... If there's another way to get a dictionary from a .txt file that'd work/is more efficient, I'm looking for help. P:

This line is stupid:

dictionary_being_manipulated = eval(dictionary_opened.read())

You are trying to evaluate all file as Python expression.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.