Skip to content

Instantly share code, notes, and snippets.

@evanhalley
Created June 7, 2017 13:10
Show Gist options
  • Save evanhalley/3d3f41eb36b917d4dae15f61c48d887c to your computer and use it in GitHub Desktop.
Save evanhalley/3d3f41eb36b917d4dae15f61c48d887c to your computer and use it in GitHub Desktop.
Reads a list of images in a directory then builds a JSON object representation with some additional metadata
from os import listdir
import json
files = listdir('./traffic_images')
data = []
# loop over the list of files and write it to an array
for image_file in files:
row = {}
row['filename'] = image_file
row['is_congested'] = -1
data.append(row)
# export data to json file
with open('data.json', 'w') as fp:
json.dump(data, fp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment