Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. with open('test.txt', 'r') as f:
  2. data = f.read()
  3.  
  4. data = data.split("n")
  5. list_of_lists = [row.split(",") for row in data]
  6. final_list = [{"building_type": row[0].strip(),
  7. "material": row[1].strip(),
  8. "your_keys": row[2].strip()} for row in list_of_lists]
  9. print(final_list)
  10.  
  11. [{'building_type': 'house', 'material': 'brick', 'your_keys': '876'},
  12. {'building_type': 'apartment', 'material': 'wood', 'your_keys': '345'},
  13. {'building_type': 'condominium', 'material': 'brick', 'your_keys': '453'}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement