-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_automation.py
More file actions
45 lines (34 loc) · 1.06 KB
/
csv_automation.py
File metadata and controls
45 lines (34 loc) · 1.06 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import csv
'''
Our task was to separate the rows where email and phone number
is matched with another google sheet with their mode of participation. As I was in hurry
and had tried multiple times, I couldn't find the way to do
the same using google sheet itself, hence I decided to download
the sheets into csv and then manipulate the files using python
and then upload the csv back to google sheets
'''
root = []
email_ph = '''
Here we had emails and phone nos
of participants separated by tab
For obvious reasons I had to hide those
'''.split('\n')
x=[]
for i in email_ph:
x.append(i.split("\t"))
email_ph = x
dictionary = {}
for i in email_ph[:-1]:
dictionary[i[0]] = i[1]
with open("./Downloads/Mode of Participation - Sheet8.csv") as csvfile:
rows = csv.reader(csvfile, delimiter=",")
for row in rows:
root.append(row)
final = []
for i in root:
if i[4] in dictionary:
i+=[dictionary[i[4]]]
with open('final.csv', "w", newline="") as csvfile:
file = csv.writer(csvfile, delimiter=",")
for i in root:
file.writerow(i)