help on Implementing a list of dicts with no data pattern

Neil Cerutti neilc at norwich.edu
Thu May 9 09:08:56 EDT 2013


On 2013-05-09, rlelis <ricardo.lelis3 at gmail.com> wrote:
> This is what i have for now:
>
> highway_dict = {}
> aging_dict = {}
> queue_row = []
> for content in file_content:
> 	if 'aging' in content:
> 		# aging 0 100
> 		collumns = ''.join(map(str, content[:1])).replace('-','_').lower()
> 		total_values =''.join(map(str, content[1:2]))
> 		aging_values = ''.join(map(str, content[2:]))
>
> 		aging_dict['total'], aging_dict[collumns] = total, aging_values
> 	queue_row.append(aging_dict)
>
> 	if 'highway' in content:
> 		#highway	|	4 	|	disable |	25
> 		collumns = ''.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_row.append(highway_dict)

Can you provide a short example of input and what you had hoped
to see in the lists and dicts at the end?

-- 
Neil Cerutti



More information about the Python-list mailing list