Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # Name: formatJSON.py
- # Purpose: converts shapfile to formated json for leaflet database application.
- # Author: noah.huntington
- # Created: 30/09/2015
- # Copyright: (c) noah.huntington 2015
- # Licence: <your licence>
- #-------------------------------------------------------------------------------
- import arcpy, os
- def main():
- fc = 'E:\db_map\IRExport_100215.csv'
- fields = ['JOBNUMBER','LatitudeI', 'LongitudeI','CARDODB PATH']
- ## fl = arcpy.MakeFeatureLayer_management(fc)
- with arcpy.da.SearchCursor(fc, fields) as cursor:
- for row in cursor:
- print '{'
- print '"job_number": "{0}",' .format(row[0])
- print '"lat": "{0}",' .format(row[1])
- print '"long": "{0}",' .format(row[2])
- if row[3][:1] == 'F':
- removeTrailing = os.path.split(row[3])[0]
- url = os.path.split(removeTrailing)[0]
- print '"url": "file://{0}"' .format(url)
- else:
- print '"url": "file://{0}"' .format(row[3][:-1])
- print '},'
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement