Created
June 7, 2017 13:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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