-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombine_finalized.py
More file actions
49 lines (42 loc) · 1.32 KB
/
combine_finalized.py
File metadata and controls
49 lines (42 loc) · 1.32 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
46
47
48
49
import csv
def open_files(array2):
for k, v in array.items():
temporary = []
with open(v, 'r', encoding='utf8') as z:
y = z.read().split('\n')
reader = csv.reader(y)
for row in reader:
try:
if len(row[0].strip(" ")) > 1:
temporary.append(row)
except:
pass
array[k] = temporary
return array
jobs = 'data/people/1April text2csv (1).csv'
people = 'data/people/apollo-contacts-export (51).csv'
array = {'jobs': jobs, 'people': people}
files = open_files(array)
jobs = files['jobs']
people = files['people']
# print(people)
final = []
processed = []
for i, v in enumerate(jobs):
start = True
if v[1].lower() not in processed:
processed.append(v[1].lower())
for index, data in enumerate(people):
# print(v, data)
if v[3].lower() == data[7].lower():
if start:
for z in range(1, 4):
final.append(" ")
start = False
final.append(v + data)
# break
print(final)
print(len(final))
with open('data/people/31 March BA final data.csv', "w", encoding='UTF8', newline='') as r:
writer = csv.writer(r)
writer.writerows(final)