I apologize once again. Is my first post here and i'm getting used to the group as long as i get the feedback of my errors by you guys. I'm using Python 2.7.3 with no dependencies, i'm simply using the standard library. Here is the "big picture" of the scenario(i have added it in the pastebin link too)
FILE OUTPUT DESIRED: aging: aging |total |age aging |0 |100 aging |2 |115 aging |3 |1 aging |4 |10 highway: highway | lanes | state | limit(mph) highway | 4 | disable | 25 highway | 2 | disable | 245 highway | 3 | disable | 125 highway | 2 | enable | 255 highway | 3 | disable | 212 highway | 8 | disable | 78 FILE INPUT EXCERPT EXAMPLE: aging 0 100 aging 2 115 aging 3 1 highway 4 disable 25 highway 2 disable 245 highway 0 enable 125 Meanwhile i have change the code a little bit and achieve a output closer to what i want: highway_dict = {} aging_dict = {} queue_counters={} queue_row = [] for content in file_content: if 'aging' in content: # aging 0 100 columns = ', '.join(map(str, content[:1])).replace('-','_').lower() total_values =''.join(map(str, content[1:2])) aging_values = '\t'.join(map(str, content[2:])) aging_dict['total'], aging_dict[columns] = total, aging_values queue_counters[columns] = aging_dict if 'highway' in content: #highway | 4 | disable | 25 columns = ''.join(map(str, content[:1])).replace('-','_').lower() lanes_values =''.join(map(str, content[1:2])) state_values = ''.join(map(str, content[2:3])).strip('') limit_values = ''.join(map(str, content[3:4])).strip('') highway_dict['lanes'], highway_dict['state'], highway_dict['limit(mph)'] = lanes, state, limit_values queue_counters[columns] = highway_dict queue_row.append(queue_counters) Now i'm adding the different dicts to a "main" one (queue_counters). The problem here is that i'm keeping falling on the iteration issue. I only get the last row on my ouput. My last printout was: queue_counters: {'aging': {'age': '10', 'total': '4'}, 'highway': {'lanes': '8','state': 'disable', 'limit': '78'}} @Dave Angel "The sample, or the description, should indicate if repeats of the "columns" column are allowed, as with b and B above. " - Yes the columns repetition are allowed. "That line tries to get clever, and ends up obscuring what's really happening. Further, the value in total, if any is NOT what you just extracted in total_values." - this variable name total_values means that i'm storing the content (different values)of the total column, and the same applies to the other columns (might not be the best names, but don't forget that we are just prototyping here). The total, age, etc etc variable name i had to set them, once they don't come with the original file, but is important to give them names to help on RDBMs purposes later, and not only that, it's handy right? The column variable refers to the object name (aging and highway). I'm doing that because in the original source i have to deal with string formatting of strange names. Remember that this is for prototyping, that's why i'm trying to resume things here. -- http://mail.python.org/mailman/listinfo/python-list