help on Implementing a list of dicts with no data pattern

Dave Angel davea at davea.name
Thu May 9 14:19:38 EDT 2013


On 05/09/2013 12:14 PM, rlelis wrote:
> On Thursday, May 9, 2013 12:47:47 AM UTC+1, rlelis wrote:
> @Dave Angel
> this is how i mange to read and store the data in file.
> data = []
> # readdata
> f = open(source_file, 'r')
> for line in f:
>          header = (line.strip()).lower()
>          # conditions(if/else clauses) on the header content to filter desired data
>          data.append(header)
>

 From earlier message:
 > highway_dict = {}
 > aging_dict = {}
 > queue_counters={}
 > queue_row = []
 > for content in file_content:
         if 'aging' in content:

So your data is a list of strings, each representing one line of the 
file.  When you run this, you'll get something like:

NameError: name 'file_content' is not defined

If I assume you've just neglected to include the assignment, 
file_content = data, then the next problem is

          if 'aging' in content:

will never fire.  Likewise
         if 'highway' in content:

will never fire.  So the rest of the code is irrelevant.

-- 
DaveA



More information about the Python-list mailing list