Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('test.txt', 'r') as f:
- data = f.read()
- data = data.split("n")
- list_of_lists = [row.split(",") for row in data]
- final_list = [{"building_type": row[0].strip(),
- "material": row[1].strip(),
- "your_keys": row[2].strip()} for row in list_of_lists]
- print(final_list)
- [{'building_type': 'house', 'material': 'brick', 'your_keys': '876'},
- {'building_type': 'apartment', 'material': 'wood', 'your_keys': '345'},
- {'building_type': 'condominium', 'material': 'brick', 'your_keys': '453'}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement