-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSearchesParser.py
More file actions
28 lines (17 loc) · 857 Bytes
/
SearchesParser.py
File metadata and controls
28 lines (17 loc) · 857 Bytes
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
import json
import time
def parseSearches(searchesFile, begintimeframe = 0, endtimeframe = int(time.time())) :
searches = json.load(open(searchesFile, 'r'))
listOfsearches = []
for search in searches["event"]:
#a query can contain several timestap so special measurments need te be implemented in order to handle it
for timeStampDic in search["query"]['id'] :
timeStamp = int(timeStampDic["timestamp_usec"]) // 1000000
# time filtering
if timeStamp < endtimeframe and timeStamp > begintimeframe:
#timeStamp = timeStamp / 1000
queryText = str(search["query"]["query_text"])
searchInfo = timeStamp, 'Searches', \
"Query Text: " + queryText
listOfsearches.append(searchInfo)
return listOfsearches