childfc = r"C:\Temp\MyGDB\Stores" parentfc = r"\\sharedrive\ParentGDB\Stores" result = arcpy.FeatureCompare_management(parentfc, childfc, "DID", "ATTRIBUTES_ONLY", "", "", "", "", "", "", "NO_CONTINUE_COMPARE") print "Comparison Result is: " + result result.GetOutput
Comparison Result is: <bound method Result.getOutput of <Result ''>>
I dont understand why my result object is coming up empty.
childfc = r"C:\Temp\MyGDB\Stores" parentfc = r"\\sharedrive\ParentGDB\Stores" result = arcpy.FeatureCompare_management(parentfc, childfc, "DID", "ATTRIBUTES_ONLY", "", "", "", "", "", "", "NO_CONTINUE_COMPARE") print "Comparison Result is: " + result.getOutput(1) result.GetOutput(1)
Comparison Result is: false u'false'
Hello John,
Have you considered using editor tracking instead? This will create columns in the attribute table indicating the edits made to the feature class, this you can access using python.
About tracking an editor's changes to data—Help | ArcGIS for Desktop
Like mentioned in the previous posts, unless it is a shapefile, the date modified for file geodatabase feature class cannot be displayed in ArcCatalog. Even the edits made to the feature class, does not affect the time stamp on the geodatabase itself until all the locks are released (this is also considered an "edit" on the gdb) i.e. till the application is closed which may not be the time you stopped editing.
Therefore, editor tracking is definitely better option if you want to track changes made to the feature class. Feature Compare essentially compares the properties of two feature classes in terms of geometry, attrribute, schema and spatial reference.
Hope this helps!
Thanks,
Best,
Vandana
wrt "the date modified for file geodatabase feature class cannot be displayed in ArcCatalog.": It works in in ArcCatalog 10.3:
(editor tracking is still a good idea).
Have people noticed that these statistics do not appear until metadata is built for the geodatabase and needs to be refreshed to get featurecounts and dates? That is the clue on how to get these details programatically. You can't read the imbedded metadata easily because it is stored as a BLOB, but you can export it to XML and then read it with Python. All the tools are there to export metadata and the standard python module Xtree can extract what you need. No need for ArcObjects at all.
1. arcpy.management.SynchronizeMetadata(....)
2.arcpy.conversion.ExportMetadata(...)
3. import xml.etree.ElementTree as ET
tree = ET.parse(xmlfile)
[get required elements]
Great point! Follow the https://community.esri.com/groups/metadata?sr=search&searchId=cfc9e661-c780-4fd7-9a16-821a22ba810d&s...!
Nice!
Unfortunately none of these methods (viewing in ArcCatalog or exporting metadata) seem to work for raster datasets inside file geodatabases...
Getting the modified date of a .gdb table/feature class took some real acrobatics, but I was finally able to get it done. I started out with zero ArcObjects experience but a good dose of Python and arcpy.
Step one was to carefully follow the instructions here:
How do I access ArcObjects from Python? - Geographic Information Systems Stack Exchange
and here:
python - ArcObjects + comtypes at 10.1 - Geographic Information Systems Stack Exchange
Once I got the "create point" code working (from the example in the first link), I opened up the Snippets.py code and inserted the following function under the *** Standalone *** section, where gdb is the full path to the gdb and tableName is the table name:
def GetModifiedDate(gdb, tableName):
# Setup
GetStandaloneModules()
InitStandalone()
import comtypes.gen.esriSystem as esriSystem
import comtypes.gen.esriGeoDatabase as esriGeoDatabase
import comtypes.gen.esriDataSourcesGDB as esriDataSourcesGDB
# Open the FGDB
pWS = Standalone_OpenFileGDB(gdb)
# Create empty Properties Set
pPropSet = NewObj(esriSystem.PropertySet, esriSystem.IPropertySet)
pPropSet.SetProperty("database", gdb)
# Cast the FGDB as IFeatureWorkspace
pFW = CType(pWS, esriGeoDatabase.IFeatureWorkspace)
# Open the table
pTab = pFW.OpenTable(tableName)
# Cast the table as a IDatasetFileStat
pDFS = CType(pTab, esriGeoDatabase.IDatasetFileStat)
# Get the date modified
return pDFS.StatTime(2)
Finally, I created a script that implemented the function (set up for a custom script tool but could be used as a stand-alone as well):
import Snippets import datetime import arcpy import sys # User Params file_gdb = arcpy.GetParameterAsText(0) # Path to FGDB table_name = arcpy.GetParameterAsText(1) # Table or feature class name arcpy.env.workspace = file_gdb if file_gdb.split(".")[-1] != "gdb": arcpy.AddMessage("The input workspace is not a file geodatabase!") sys.exit() def doIt(file_gdb, table_name): # Call GetModifiedDate function to get the number of seconds num_seconds = Snippets.GetModifiedDate(file_gdb, arcpy.Describe(table_name).baseName) # Translate the number of seconds into a formatted date date_modified = datetime.datetime.fromtimestamp(num_seconds).strftime('%Y-%m-%d %H:%M:%S') # Report the result arcpy.AddMessage(date_modified) return date_modified doIt(file_gdb, arcpy.Describe(table_name).baseName)
I sincerely hope this helps! Thanks to all the people who got me to an actual solution.