1import csv
2csv_columns = ['word','matchin']
3
4csv_file = "found.csv"
5try:
6 with open(csv_file, 'w') as csvfile:
7 writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
8 writer.writeheader()
9 for data in corpus:
10 writer.writerow(data)
11except IOError:
12 print("I/O error")
1mydict = {y[0]: y[1] for y in [x.split(",") for x in open('file.csv').read().split('\n') if x]}
1 pythonCopyimport pandas as pd
2
3dict_from_csv = pd.read_csv('csv_file.csv', header=None, index_col=0, squeeze=True).to_dict()
4print(dict_from_csv)
5