-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcessData.py
95 lines (84 loc) · 2.92 KB
/
ProcessData.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import ExtractInfo
import urllib2
import csv
import codecs
f = open('AllGamesUrls.txt', 'r')
list = f.readlines()
#urlToParseList = []
#urlToParseList.append(list[0])
urlToParseList=list[1:10]
label=['Title', 'Publish By', 'Developed By', 'Released', 'Platform', 'Genre', 'Perspective', 'Sport', 'Non Sport', 'Misc', 'Rank', 'Score', 'Alternate Titles', 'Part of the Groups', 'The Press Says ','Release Info']
w = csv.writer(file('data.csv', 'wb'))
w.writerow(label)
def concatRelease(o, name):
p=o.getGameRelease()[name]
rez=""
j=1
for i in p:
rez=rez+i
if(len(p)>j):
rez=rez+", "
j=j+1
return unicode(rez, errors='replace').encode('ascii', 'replace').replace('?', ' ')
def concatGenre(o, name):
p=o.getGameGenre()[name]
rez=""
j=1
for i in p:
rez=rez+i
if(len(p)>j):
rez=rez+", "
j=j+1
return unicode(rez, errors='replace').encode('ascii', 'replace').replace('?', ' ')
def concatAllMainInfo(o, name):
p=o.getAllMainInfo()[name]
rez=""
j=1
for i in p:
rez=rez+i
if(len(p)>j):
rez=rez+", "
j=j+1
return unicode(rez).encode('ascii', 'replace').replace('?', ' ')
def concatMobyRankScore(o, name):
p=o.getMobyRankScore()[name]
pltf=o.getMobyRankScore()['platform']
rez=""
j=1
for i in p:
rez=rez+pltf[j-1]+": "+i
if (len(p)>j):
rez=rez+", "
j=j+1
return unicode(rez, errors='replace').encode('ascii', 'replace').replace('?',' ')
def concatAllReleaseInfo(d):
p=d.getReleaseInfo()
keys=p.keys()
rez=""
print keys
for k in keys:
h=k+":: "
j=1
r=""
for i in p[k]:
r=r+i
if(len(p[k])>j):
r=r+", "
j=j+1
r=h+r
rez=rez+r
return unicode(rez).encode('ascii', 'replace').replace('?', ' ')
for i in urlToParseList:
print i
o = ExtractInfo.GameInfo(i)
d = ExtractInfo.ReleaseInfo(i)
g = ExtractInfo.MobyRankScore(i)
r = ExtractInfo.RatingSystems(i)
#print g.getMobyRankScorePress()
print g.getMobyRankScoreUsers()
#print r.getRatings()
#print d.getReleaseInfo()
#print o.getAllMainInfo()['pressSays']
#print o.getTitle()[0]
#w.writerow([o.getTitle()[0]]+[concatRelease(o,'publishBy')]+ [concatRelease(o,'developedBy')] + [concatRelease(o,'released')] + [concatRelease(o,'platform')] + [concatGenre(o,'genre')]+ [concatGenre(o,'perspective')]+ [concatGenre(o,'sport')]+ [concatGenre(o,'nonsport')]+ [concatGenre(o,'misc')]+[concatMobyRankScore(o,'rank')]+[concatMobyRankScore(o,'score')]+[concatAllMainInfo(o,'altTitles')]+[concatAllMainInfo(o,'partGroup')]+[concatAllMainInfo(o,'pressSays')]+[concatAllReleaseInfo(d)])
#w.writerow(o.getTitle()+o.getGameRelease()['publishBy']+o.getGameRelease()['developedBy']+o.getGameRelease()['released']+o.getGameRelease()['platform']+o.getGameGenre()['genre']+o.getGameGenre()['perspective']+o.getGameGenre()['sport']+o.getGameGenre()['nonsport']+o.getGameGenre()['misc']+[concatMobyRankScore(o,'rank')]+[concatMobyRankScore(o,'score')]);