json_explorer

exploring the google takeout location history json.

Imports

This is kinda neat that I can fire markdown in here. BTW #| export is magic to mean export it into the source file when we run nbdev_export


get_timestamp

 get_timestamp (timestamp)

Google stores the timestamp in different formats, making this annoying

Details
timestamp Example: 2022-06-24T19:38:55.633Z or 2022-06-24T19:38:55Z
# test data
test_string = "2022-06-24T19:38:55.633Z"
get_timestamp(test_string)
1656110335
test_string2 = "2022-06-24T19:38:55Z"
get_timestamp(test_string2)
1656110335
file_to_open = "sample-data/sample.json"

sample data to validate the google json export format


get_locations

 get_locations (file_to_open)
locations = get_locations(file_to_open)
len(locations)
58
locations[1]
{'latitudeE7': 446549213,
 'longitudeE7': -635836178,
 'accuracy': 45,
 'source': 'WIFI',
 'timestamp': '2016-06-29T13:13:01.899Z'}
locations[-1]
{'latitudeE7': 446551683,
 'longitudeE7': -635835479,
 'accuracy': 111,
 'source': 'WIFI',
 'timestamp': '2016-06-29T16:29:08.374Z'}

build_location_history

 build_location_history (locations)

more validation of output, note that these don’t get exported to the library

location_history = build_location_history(locations)
assert len(location_history) == 58
location_history[0]
Location(timestamp=1467216494, latitude=446549411, longitude=-635836042, accuracy=41)
location_history[-1]
Location(timestamp=1467228548, latitude=446551683, longitude=-635835479, accuracy=111)