Programmatically return Feature Class file size and date modified

17179
30
05-21-2013 06:19 AM
JohnDye
Occasional Contributor III
There doesn't appear to be a function in arcpy to return the file size of a feature class or it's date modified timestamp.

Anyone have any idea how to do this? I know there is a property somewhere because you can setup ArcCatalog to display the information. However, I want to see it returned in a Python Script so that I can write a two-way synchronization function.
Tags (2)
30 Replies
JamesCrandall
MVP Frequent Contributor
There doesn't appear to be a function in arcpy to return the file size of a feature class or it's date modified timestamp.

Anyone have any idea how to do this? I know there is a property somewhere because you can setup ArcCatalog to display the information. However, I want to see it returned in a Python Script so that I can write a two-way synchronization function.


os.path has both of the methods you want (I have not worked with these myself).

os.path.getmtime
os.path.getsize

http://docs.python.org/2/library/os.path.html
0 Kudos
ChrisSnyder
Regular Contributor III
Unless its a shapefile, I don't believe there is currently a way to do this with arcpy in v10.1.

A trick though to getting this to work is to make a seperate FGBD for each FC.

This code might give you some ideas on how to get the size:

import glob
def compactAndReportFGDB(fgdbPath): 
    oldFgdbSize = 0
    for file in glob.glob(fgdbPath + "\\*"):
        oldFgdbSize = oldFgdbSize + os.path.getsize(file)
    arcpy.Compact_management(fgdbPath)
    newFgdbSize = 0
    for file in glob.glob(fgdbPath + "\\*"):
        newFgdbSize = newFgdbSize + os.path.getsize(file)
    compactPct = str(int((oldFgdbSize - newFgdbSize) / float(oldFgdbSize) * 100))
    return compactPct
0 Kudos
JamesCrandall
MVP Frequent Contributor
Unless its a shapefile, I don't believe there is currently a way to do this with arcpy in v10.1.


Good point.  I guess you'd have to implement some kind of your own logging process on the gdb to maintain info on modification dates.  Not sure exactly how you'd work out the size of GDB elements too other than creating individual .shp files or gdb's of each item.  ewww.
0 Kudos
JamesCrandall
MVP Frequent Contributor
0 Kudos
JohnDye
Occasional Contributor III
Thanks James,
I initially thought the same thing but was skeptical since Windows doesn't natively understand the GDB format. Needless to say, this raises an error.
0 Kudos
JohnDye
Occasional Contributor III
By the looks of this http://gis.stackexchange.com/questions/23914/how-to-get-the-size-of-a-file-geodatabase-feature-class... you could probably get at this info with ArcObects someway.

edit: yup.. http://gis.stackexchange.com/questions/24242/how-to-programmatically-determine-the-size-of-a-feature... ArcObjects will get it done.


Thanks James,
I actually saw this before posting here, but I'm not sure how to leverage ArcObjects from Python, if I can at all.
0 Kudos
ChrisSnyder
Regular Contributor III
0 Kudos
JohnDye
Occasional Contributor III
Since it's not currently possible through anything I've seen in Python, I've added it to the ideas site.https://c.na9.visual.force.com/apex/ideaView?id=087E00000004eOq
0 Kudos
JohnDye
Occasional Contributor III
I've never used ArcObjects via Python but you can: http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python


sweet. I'll give it a go. thanks!
0 Kudos