forked from sumitkeswani/fakeReviewerDetection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
untitled.py
46 lines (36 loc) · 860 Bytes
/
untitled.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
import csv
file1 = "./raw_data.tsv"
file2 = "./output.csv"
reviewerprob = {}
with open(file2, 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',')
for row in spamreader:
prob = float(row[2])
if prob <= 0.45:
reviewerprob[row[1].strip()] = prob
monthfreq = {}
monthfreq[1] = 0
monthfreq[2] = 0
monthfreq[3] = 0
monthfreq[4] = 0
monthfreq[5] = 0
monthfreq[6] = 0
monthfreq[7] = 0
monthfreq[8] = 0
monthfreq[9] = 0
monthfreq[10] = 0
monthfreq[11] = 0
monthfreq[12] = 0
with open(file1, 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter='\t')
for row in spamreader:
reviewerid = row[1].strip()
# print reviewerid
if reviewerid in reviewerprob:
print "in"
date = row[8].strip()
month = int(date[0:2])
year = int(date[-4:])
if (year > 2000 and year <= 2010):
monthfreq[month] += 1
print monthfreq