Skip to content

Instantly share code, notes, and snippets.

Avatar

Ghislain Prince ghisprince

View GitHub Profile
View strava_streams_api.py
### CURRENT
# Result is a enum of streams in any order. To get a particular stream you loop through them,
# and ask for it's type. A particular requested stream is not returned if it's not
# on the activity (need to code defensively).
streams = client.get_activity_streams(123, types=types, resolution='medium')
heartrate_stream = None
for s in streams:
@ghisprince
ghisprince / pprint_fields.py
Created Aug 7, 2014
pretty print table's fields
View pprint_fields.py
import arcpy
def pprint_fields(table):
""" pretty print table's fields and their properties """
def _print(l):
print("".join(["{:>12}".format(i) for i in l]))
atts = ['name', 'aliasName', 'type', 'baseName', 'domain',
'editable', 'isNullable', 'length', 'precision',
'required', 'scale',]
_print(atts)
for f in arcpy.ListFields(table):
@ghisprince
ghisprince / export_fc_to_csv.py
Last active Dec 7, 2015
Export each vertex in a line or poly fc to a csv with OID
View export_fc_to_csv.py
def export_fc_to_csv(fc, out_csv):
"""
Export each vertex in a line or poly fc to a csv with OID
user requested at http://arcpy.wordpress.com/about/#comment-348
example
import geom_snippets
geom_snippets.export_fc_to_csv(r"c:\proj\fc1.shp", r"c:\proj\fc1.csv")
View arcpy_merge_paths.py
def connect_parts(fc):
"""
Takes each part of a line feature. If made of more than one path
(aka segment, aka part) connects them into a single path.
Vertices are unchanged.
Code authored on ArcGIS ver 10.2.2
"""
import json
with arcpy.da.UpdateCursor(fc, "Shape@JSON") as uc: