-
Notifications
You must be signed in to change notification settings - Fork 6
/
datafilter.py
69 lines (62 loc) · 2.54 KB
/
datafilter.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import csv, globalparameter
# , open('output.csv','w') as outputfile
def filter_alluser_with_jobtitle(filepath, outputfilepath, name_for_search):
with open('/Users/pengyuzhou/Desktop/LinkedIn_data_lowercase_no_punctuation.csv', 'r') as csvfile:
name = 'marketing manager'
reader = csv.reader(csvfile)
# writer = csv.DictWriter(outputfile)
i = 1
writer = csv.writer(open('/Users/pengyuzhou/Desktop/marketing_manager_lowercase_no_punctuation.csv', 'w'))
writer1 = csv.writer(open('/Users/pengyuzhou/Desktop/non_marketing_manager_lowercase_no_punctuation.csv', 'w'))
for row in reader:
print(i)
if (row[3].find(name) != -1):
writer.writerow(row)
elif (row[9].find(name) != -1):
writer.writerow(row)
elif (row[15].find(name) != -1):
writer.writerow(row)
elif (row[21].find(name) != -1):
writer.writerow(row)
elif (row[27].find(name) != -1):
writer.writerow(row)
elif (row[33].find(name) != -1):
writer.writerow(row)
elif (row[39].find(name) != -1):
writer.writerow(row)
else:
writer1.writerow(row)
i = i + 1
csvfile.close()
# outputfile.close()
def filter_alluser_with_newest_jobtitle(rawdatapath, folderpath,outputjobtitlepath, name_for_search):
with open(rawdatapath, 'r') as csvfile:
name = name_for_search
reader = csv.reader(csvfile)
# writer = csv.DictWriter(outputfile)
i = 1
writer = csv.writer(
open(folderpath + '/' + outputjobtitlepath + globalparameter.output_file_root,
'w'))
writer1 = csv.writer(
open(folderpath + '/' +'non_'+ outputjobtitlepath + globalparameter.output_file_root,
'w'))
for row in reader:
print(i)
if (row[3].find(name) != -1):
writer.writerow(row)
else:
writer1.writerow(row)
i = i + 1
csvfile.close()
def filter_data_with_job_title_oo(classlist,jobtitle_name,index):
result_list = []
if index == 1:
for i in range(len(classlist)):
if classlist[i].title.find(jobtitle_name)!=-1:
result_list.append(classlist[i])
if index == 2:
for i in range(len(classlist)):
if classlist[i].title.find(jobtitle_name)==-1:
result_list.append(classlist[i])
return result_list