Answers for "convert csv file to dictionary 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
0

csv library python convert dict to csv

import csv
my_dict = {'1': 'aaa', '2': 'bbb', '3': 'ccc'}
with open('test.csv', 'w') as f:
    for key in my_dict.keys():
        f.write("%s,%sn"%(key,my_dict[key]))
Posted by: Guest on August-24-2021
1

python create dictionary from csv

mydict = {y[0]: y[1] for y in [x.split(",") for x in open('file.csv').read().split('n') if x]}
Posted by: Guest on October-02-2020
1

how to create dictionary in python from csv

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

Code answers related to "convert csv file to dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language