I have the python code that filters the data according to a specific column and creates multiple CSV files.
My python logic currently produces a separate csv for separate cities. Existing python logic is:
from itertools import groupby
import csv
with open('filtered_final.csv') as csv_file:
reader = csv.reader(csv_file)
next(reader) #skip header
#Group by column (city)
lst = sorted(reader, key=lambda x : x[1])
groups = groupby(lst, key=lambda x : x[1])
#Write file for each city
for k,g in groups:
filename = k[21:] + '.csv'
with open(filename, 'w', newline='') as fout:
csv_output = csv.writer(fout)
csv_output.writerow(["Name","City","Email"]) #header
for line in g:
csv_output.writerow(line)