how do i search for a row in a csv in python and putting it in a different file using this code: -
import re import csv open('a.csv','r') f: r = csv.reader(f) dict2 = {row[0]: row[1:] row in r} open('b.csv', 'r') f: r = csv.reader(f) dict1 = {row[0]: row[1:] row in r} fine = {k: (dict1[k], dict2[k]) k in set(dict1).intersection(dict2)} open('c.csv', 'w') f: w = csv.writer(f) value in fine.items(): w.writerow(value)
please help, cant find how input csv, doing school please can me solve way change searches row includes words in first 2 csv s
one of those?
for value in fine.items():: unpacked_value = [elem lst in value elem in lst] w.writerow(unpacked_value)
for value in fine: row in fine[value]: w.writerow((value, row))
Comments
Post a Comment