You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
not sure if each download is unique, but I had to change some things to work with the takeout zip I made 2023-01-25
filename changed from "Location History.json" to "Records.json"
"timestampMs" is not present, "timestamp" is roughly iso timestamp
defget_timestamp_ms(raw_timestamp):
try:
returndatetime.datetime.strptime(raw_timestamp, "%Y-%m-%dT%H:%M:%SZ").timestamp()
exceptValueError:
returndatetime.datetime.strptime(raw_timestamp, "%Y-%m-%dT%H:%M:%S.%fZ").timestamp()
defsave_location_history(db, zf):
location_history=json.load(
zf.open("Takeout/Location History/Records.json")
)
db["location_history"].upsert_all(
(
{
"id": id_for_location_history(row),
"latitude": row["latitudeE7"] /1e7,
"longitude": row["longitudeE7"] /1e7,
"accuracy": row["accuracy"],
"timestampMs": get_timestamp_ms(row["timestamp"]),
"when": row["timestamp"],
}
forrowinlocation_history["locations"]
),
pk="id",
)
defid_for_location_history(row):
# We want an ID that is unique but can be sorted by in# date order - so we use the isoformat date + the first# 6 characters of a hash of the JSONfirst_six=hashlib.sha1(
json.dumps(row, separators=(",", ":"), sort_keys=True).encode("utf8")
).hexdigest()[:6]
return"{}-{}".format(
row['timestamp'],
first_six,
)
not sure if each download is unique, but I had to change some things to work with the takeout zip I made 2023-01-25
filename changed from "Location History.json" to "Records.json"
"timestampMs"
is not present,"timestamp"
is roughly iso timestampexample locations from mine
The text was updated successfully, but these errors were encountered: