Skip to content

Instantly share code, notes, and snippets.

@chadcooper
Created August 9, 2013 13:33
Show Gist options
  • Save chadcooper/6193617 to your computer and use it in GitHub Desktop.
Save chadcooper/6193617 to your computer and use it in GitHub Desktop.
Finds a specified prj file in the ArcGIS Coordinate Systems directory.
import os, fnmatch, arcpy
def locate(pattern, root=arcpy.GetInstallInfo()["InstallDir"] + "\Coordinate Systems"):
"""Locate all files matching supplied filename pattern in and below
supplied root directory.
"""
for path, dirs, files in os.walk(os.path.abspath(root)):
for filename in fnmatch.filter(files, pattern):
yield os.path.join(path, filename)
prj = "Asia_Lambert_Conformal_Conic"
for f in locate(prj.replace("_", " ") + ".prj"):
try:
file_object = open(f, "r")
all_text = file_object.read()
print all_text[:6]
finally:
file_object.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment