wip
This commit is contained in:
27
loader.py
27
loader.py
@@ -58,6 +58,33 @@ def load(folder):
|
||||
return users, posts, firstcontrib, sumcontrib
|
||||
|
||||
|
||||
def readVotes(folder):
|
||||
file = folder + "/Votes.xml"
|
||||
prefix = "readVotes: "
|
||||
printnoln(prefix + "reading xml file ...")
|
||||
|
||||
now = cms()
|
||||
items = [elem for event, elem in et.iterparse(file) if elem.tag == "row"]
|
||||
rprint(prefix + "reading xml file ... took " + str(cms() - now) + "ms")
|
||||
|
||||
votes = dmt(items).map(mapvote, prefix + "mapping votes").getresults()
|
||||
|
||||
print(prefix + "done")
|
||||
return votes
|
||||
|
||||
|
||||
def mapvote(item):
|
||||
tags = ['PostId', 'VoteTypeId', 'CreationDate']
|
||||
datetags = ['CreationDate']
|
||||
vote = {tag: getTag(item, tag) for tag in tags}
|
||||
for tag in datetags:
|
||||
if vote[tag] is not None:
|
||||
vote[tag] = datetime.fromisoformat(vote[tag])
|
||||
else:
|
||||
print("map vote: tag " + tag + " is None: " + str(vote))
|
||||
return vote
|
||||
|
||||
|
||||
def computesumcontrib(posts):
|
||||
x1 = dmt(posts).map(lambda q: q['OwnerUserId'], "calc sum contrib q").getresults()
|
||||
x2 = dmt(posts).map(lambda q: [a['OwnerUserId'] for a in q['Answers']], "calc sum contrib a").getresults()
|
||||
|
||||
Reference in New Issue
Block a user