-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_csv.py
27 lines (23 loc) · 850 Bytes
/
read_csv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import csv
import email_sender
def main(csv_file):
with open(csv_file) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
print(csv_file, '\n', csv_reader)
for row in csv_reader:
if line_count == 0:
print(f'Column names are {", ".join(row)}')
line_count += 1
else:
print(
f'\t{row[0]} email id is \t\t{row[2]} works at \t{row[3]}.')
line_count += 1
first_name, email = email_sender.set_content(
to_email_id=row[2], first_name=row[0])
email_sender.send_email(first_name, email)
if line_count == 2:
break
print(f'Processed {line_count} lines.')
csv_file = 'test.csv'
main(csv_file)