Toggle labels in a map document

I had a request from the Asset Management team to display all the asset management data I had for a particular area, grouped by service category and with labels displaying their unique IDs. My challenge was to turn on the labels for all the layers using a specific expression. However, the ID fields were not named the same in all the layers (again, the joys of working with data received from outside).

On line 19, I set the label expression for the default label class using the correct field name. The square brackets are what ArcGIS is expecting to delimit field names in the label expression dialog. Line 20 turns the labels on, while line 23 turns the layer on.

Convert multiple spreadsheets to geodatabase tables

For years I used the old ArcGIS way of connecting ArcGIS to Excel – saving the tables as dbf files. That was terrible. In 10.2 ESRI added a new conversion toolset for moving back and forth between Excel and ArcGIS.

It is a set of Python scripts using xlrd/xlwt. For a while, I was reading in individual sheets into memory and doing things with them using openpyxl. While that workflow is still valid, most of the time I actually want a gdb table copy of my spreadsheet before I start working with it.

I received a folder containing multiple subfolders with months/years in the folder names. Each subfolder contained multiple spreadsheets with different names. The spreadsheets followed two different field naming conventions.

Since I was not going to be manually processing these dozens of files, I wrote this script to help me.

The script is fairly simple. It loops over all the files in the main folder, as well as recursively into the subfolders. Any characters ArcGIS does not like are replaced with underscores, and each sheet is converted to a geodatabase table.

ArcMap Woes Part 1: Random fail in ArcMap works in ArcCatalog

Today I tried to run a script in ArcMap. Nothing fancy, just exporting data driven pages as jpegs in a for loop (basically taken straight from the help docs 2 years ago, and used in endless variations since):

Of course, ArcMap crashes. No, not crashes, because then it would pop up the ESRI “Send Error Report” dialog box. It simply terminates. I run the same script in ArcCatalog and it works perfectly. Note that I have run scripts like this many times before in ArcMap without any issues. It’s almost as if ArcMap gets tired of certain things, and refuses to cooperate. I’m pretty sure if I try this script in ArcMap again in a few days time it will be fine.