Skip to content

Commit eb421d8

Browse files
committed
Rushang stuff
1 parent 7169bfa commit eb421d8

File tree

8 files changed

+65
-370
lines changed

8 files changed

+65
-370
lines changed

automate.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
from scrape import scraper
2-
from csv_utils import read_csv, write_csv, get_unpaid_participants
2+
from file_utils import *
33
from generate import _render_template
44
from mail import sendmail
55
import json
66

77
data = scraper('http://scrape.surge.sh/')
8-
write_csv(data, "studentdetails.csv")
8+
write_csv(data)
99

10-
unpaid_participants, paid_count = get_unpaid_participants("studentdetails.csv")
11-
total_seats = 500
10+
paid_participants = get_paid_participants()
11+
mails = []
1212

13-
for participant in unpaid_participants:
14-
html = _render_template(participant[0], total_seats-paid_count)
15-
sendmail(to_email=participant[0], html=html)
13+
for participant in paid_participants:
14+
# html = _render_template(participant[3])
15+
# response = sendmail(to_email=participant[3], html=html)
16+
if response['email_status'] == "Success":
17+
mails.append(participant[3])
18+
write_file(participant[3])

csv_utils.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

file_utils.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import csv
2+
3+
def read_csv():
4+
with open("studentdetails.csv", 'r') as csv_file:
5+
csv_reader = csv.reader(csv_file, delimiter=',')
6+
data = []
7+
for row in csv_reader:
8+
data.append(row)
9+
10+
return data
11+
12+
def write_csv(data):
13+
with open("studentdetails.csv", 'w') as csv_file:
14+
csv_writer = csv.writer(csv_file, delimiter=',')
15+
for row in data:
16+
csv_writer.writerow(row)
17+
18+
def read_file():
19+
with open("sentmails.txt", 'r') as f:
20+
sent_mails = f.readlines()
21+
return sent_mails
22+
23+
def write_file(mail):
24+
with open("sentmails.txt", 'a') as f:
25+
f.write(mail + "\n")
26+
27+
def get_paid_participants():
28+
participants = read_csv()
29+
paid_participants = []
30+
mails = read_file()
31+
for participant in participants:
32+
if participant[-1] == 'paid' and participant[3] not in mails:
33+
paid_participants.append(participant)
34+
return paid_participants

generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ def _render_template(name, seats):
1010
lstrip_blocks=True,
1111
keep_trailing_newline=True,
1212
)
13-
template = env.get_template('remind.html')
13+
template = env.get_template('confirmation.txt')
1414
return template.render(name=name, seats=seats)

sentmails.txt

Whitespace-only changes.

studentdetails.csv

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
Name,DOB,City,Email,Phone,Payment
22
Akshay,09-10-1999,Mumbai,[email protected],9699923802,paid
3-
Karan,15-06-1999,Mumbai,[email protected],7715905009,unpaid
3+
Karan,15-06-1999,Mumbai,[email protected],7715905009,paid
44
Rushang,04-11-1999,Mumbai,[email protected],9619243034,paid
5-
Aditya,10-06-1999,Mumbai,[email protected],7977475158,unpaid
5+
Aditya,10-06-1999,Mumbai,[email protected],7977475158,paid
66
Hetal,24-06-1999,Mumbai,[email protected],9819746588,paid
7+
Jordan Green,1971-10-05,East Brian,[email protected],443-660-8596x55035,paid
8+
Andrea Buck,2017-03-02,East Erinhaven,[email protected],0449105990,unpaid
9+
Donald Harvey,2005-03-21,Petersport,[email protected],(797)677-7427x05906,unpaid
10+
Jacqueline Nunez,1996-10-12,West Lauren,[email protected],248.899.0545x43746,paid
11+
Christina Butler,2008-03-05,Sethland,[email protected],(699)852-8818x0541,unpaid
12+
Amanda Torres,1982-05-10,Danielsport,[email protected],(884)289-8460x062,unpaid
13+
Natalie Goodwin,1981-03-14,East Samuelberg,[email protected],098-809-3668,unpaid
14+
Christian Gordon,1973-10-09,Lake Samantha,[email protected],398.172.7364,unpaid
15+
Robin Nicholson,2005-06-21,Howardfurt,[email protected],+1-588-564-5335x5284,unpaid
16+
Lynn Carpenter,1991-08-25,Port Nicholasstad,[email protected],004-439-7244,paid
17+
Ethan Rios,2003-04-04,North Waynestad,[email protected],556-895-7010,paid
18+
Bruce Fisher,2014-07-12,Kennedyhaven,[email protected],001-322-151-4142x156,unpaid
19+
Lisa Flores,2019-07-10,West Charles,[email protected],679.853.7037x714,unpaid
20+
Sharon Savage,1977-07-03,Port Meagan,[email protected],908-821-5020,unpaid
21+
Kathy Harris,2002-12-15,South Charlesmouth,[email protected],+1-973-444-5430x01717,unpaid
22+
Michael Young,2002-02-08,Zhangland,[email protected],981-695-0187x3567,paid
23+
Danny Young,1980-04-26,Port Alexandra,[email protected],243-607-4908,paid

templates/confirmation.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hi {{name}},

0 commit comments

Comments
 (0)