import os import arcpy workspace = r"C:\working\roger" output = r"C:\testlist.txt" def inventory_data(workspace, datatypes, output): """ Generates full path names under a catalog tree for all requested datatype(s). Parameters: workspace: string The top-level workspace that will be used. datatypes: string | list | tuple Keyword(s) representing the desired datatypes. A single datatype can be expressed as a string, otherwise use a list or tuple. See arcpy.da.Walk documentation for a full list. """ with open(output, "w") as outFile: for path, path_names, data_names in arcpy.da.Walk( workspace, datatype=datatypes): for data_name in data_names: outFile.write(os.path.join(path, data_name) + os.linesep) inventory_data(workspace, "Any", output)
import os import arcpy workspace = r"T:\test" output = r"H:\testlist.txt" def inventory_data(workspace, datatypes): """ Generates full path names under a catalog tree for all requested datatype(s). Parameters: workspace: string The top-level workspace that will be used. datatypes: string | list | tuple Keyword(s) representing the desired datatypes. A single datatype can be expressed as a string, otherwise use a list or tuple. See arcpy.da.Walk documentation for a full list. """ for path, path_names, data_names in arcpy.da.Walk( workspace, datatype=datatypes): for data_name in data_names: yield os.path.join(path, data_name) with open(output, "w") as outFile: for f in inventory_data(workspace, "Any"): outFile.write(f + os.linesep)
I'm new to Python. The 'workspace' variable is confusing to me. Do I need a file to be located at that location? Or should that point to my GIS DB server?
In this case, I think the workspace variable is simply where to start the searching. You could also look into using arcpy.da.Walk().
The workspace variable is the root directory you want it to search for spatial data. So if you set it to "C:/" it would check all folders and subfolders in the C drive for spatial data and write it to a report. If you have a particular folder within a drive say "D:/ForestryData" that has folders and subfolders to be checked and used that as the workspace it would check all folders and subfolders of "D:/ForestryData" for data. I'm not sure if you can point it at a database connection or not.
I work with Enterprise databases so I have to create SDE connections to datasets within databases. SQL Server. So I don't have a mapped drive letter that will do this. Is there an option for Enterprise level database settings?
It's still just an SDE connection file. You can either save your connection file to a local (or network) drive, or you can refer to the connection files with a relative path in ArcCatalog as simply "Database Connections\MyConnectionFile.sde"
The ArcCatalog connection files are actually stored in a hidden folder at C:\Users\usernamehere\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog
I like to have an explicit location where the connection file is. If you had the ArcCatalog relative path, the connections available depend on the particular user logged in to the machine running the script.