Created
August 9, 2013 13:33
-
-
Save chadcooper/6193617 to your computer and use it in GitHub Desktop.
Finds a specified prj file in the ArcGIS Coordinate Systems directory.
This file contains hidden or 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
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