Answers for "how to convert csv to dict in python"

2

python dictionary to csv

import csv
csv_columns = ['word','matchin']

csv_file = "found.csv"
try:
    with open(csv_file, 'w') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
        writer.writeheader()
        for data in corpus:
            writer.writerow(data)
except IOError:
    print("I/O error")
Posted by: Guest on February-17-2021
1

how to create dictionary in python from csv

input_file = csv.DictReader(open("coors.csv"))
Posted by: Guest on March-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language