Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = '\t'.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)
- # 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 disable 125
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement