JSON Import Format

Here a little bit of Python that takes an Arc JSON export and converts it into the separate TimelineItem LocomotionSample and Place files.

Anyone running this will need to create the three output folders (TimelineItem LocomotionSample Place) before they run the script on their data.

import json

with open('<input file>.json') as file:
    data = json.load(file)

places = {}
timelineItem = {}
samples = []

for item in data['timelineItems']:
    if item.get('place'):
        places[item['place']['placeId']] = item['place']

    if item.get('samples'):
        samples += item['samples']
        del item['samples']

    timelineItem[item['itemId']] = item

with open('LocomotionSample/samples.json', 'w') as file:
    json.dump(samples, file, indent=2)

for id, item in timelineItem.items():
    with open(f'TimelineItem/{id}.json', 'w') as file:
        json.dump(item, file)

for id, item in places.items():
    with open(f'Place/{id}.json', 'w') as file:
        json.dump(item, file)
1 Like