Category Archive: Python

Apr 30

Using python to repair data sources

This is really here for me to remember these.  But two lines of python code can be used to change the data source of your current MXD.  Thanks to Malcolm Lobley of Delo Solutions for this tip.   mxd = arcpy.mapping.MapDocument(“CURRENT”) mxd.replaceWorkspaces(“”, “”, r’Database Connections\Connection To SDE.sde’, “SDE_WORKSPACE”)    

Jul 23

Python and GeoProcessing on Linux, part 1

After reading this ESRI blog post, I decided to give this a try with ArcGIS 10.  I love playing with Linux, and I’m pretty good with Python, so this seemed like a fun experiment. I set up a VirtualBox VM with Fedora 13 (32-bit).  Next, I installed Eclipse.  The Fedora version of Eclipse installs PyDev …

Continue reading »

Dec 19

Find recent files via python

Here is a quick little python blurb to find any files in a given directory within a certain time.  I use this in my nightly scripts to find my lastest database backups, exports, shapefiles, etc.   Hope it helps.   import os, datetime, stat NOW = datetime.datetime.now() TWELVE = datetime.timedelta(hours=12) FORMAT = "%a %b %d %Y …

Continue reading »