Skip to content

Instantly share code, notes, and snippets.

@hamilton
Last active December 3, 2019 03:31
Show Gist options
  • Save hamilton/e0c631a0fab4655bdc9943e4a16eeff6 to your computer and use it in GitHub Desktop.
Save hamilton/e0c631a0fab4655bdc9943e4a16eeff6 to your computer and use it in GitHub Desktop.
plotting SFMTA coords using pandas + datashader + imagemagick
##### use this to get data in a format for the jupyter notebook
import csv
from os import listdir
from os.path import isfile, join
from math import floor
# take everything from one
# output time of day, lat, lon, that's it.
PATH = '../data/'
fieldnames = ['time', 'vehicle_tag', 'lat', 'lon']
OUT = csv.DictWriter(open('out_segs.csv', 'w'), fieldnames)
OUT.writeheader()
for filename in [[f for f in listdir(PATH) if isfile(join(PATH, f))][0]]:
r = csv.DictReader(open(join(PATH,filename), 'r'))
print('processing', filename)
for row in r:
time = row['REPORT_TIME'][11:]
time = time.split(':')
time = '{}:{}:00'.format(time[0], time[1])
OUT.writerow({'time': time, 'lat': row['LATITUDE'], 'lon': row['LONGITUDE'], 'vehicle_tag': row['VEHICLE_TAG']})
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment