-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformatdata.py
51 lines (40 loc) · 1.08 KB
/
formatdata.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
import json
import csv
import numpy as np
from datetime import datetime
with open('GoogleLocationHistory.json',"r") as geo_json_file:
data = json.load(geo_json_file)
maxVal=0
maxIndex=0
checkLen=1
flow=1
i=0
while flow==1:
try:
checkLen=len(data['locations'][i])
if checkLen > maxVal:
maxVal=checkLen
maxIndex=i
i=i+1
except:
print('List length index:',i,' with max length:',maxVal,' at ',maxIndex)
flow=0
listLen=i
locs=np.zeros((listLen,2))
for j in range(0,listLen):
indStr=str(data['locations'][j])
tup=indStr.rpartition("latitudeE7': ")
tempStr=tup[2].split(',',1)[0]
tempInt=int(tempStr)
if tempInt>1800000000:
tempInt=tempInt-4294967296
tempInt=tempInt/(10**7)
locs[j][0]=tempInt
tup=indStr.rpartition("longitudeE7': ")
tempStr=tup[2].split(',',1)[0]
tempInt=int(tempStr)
if tempInt>1800000000:
tempInt=tempInt-4294967296
tempInt=tempInt/(10**7)
locs[j][1]=tempInt
np.savetxt('locations.csv',locs, delimiter=',')