May-14-2020, 10:43 AM
If use csv module and DictReader.
It will give you that structure bye default.
It will give you that structure bye default.
import csv with open("log.csv") as f: records = csv.DictReader(f) for row in records: print(row)
Output:{'name': 'xxx', 'origin': 'uk', 'dest': 'france'}
{'name': 'yyyy', 'origin': 'norway', 'dest': 'finland'}
{'name': 'zzzz', 'origin': 'denmark', 'dest': 'canada'}