I'm not sure what the best way is to go about this, but here's my situation:
In short, I exported a domain to a table (and I exported the table as a CSV, too, just in case it might be easier to work with), and I need to be able to reference the descriptions from the table to replace text on a map template in a Python script. I have a layer that has an attribute that is the same as the coded value in the domain, and whenever I replace the template text for that object, it needs to be able to see whatever the code is in the attribute table and replace the generic template text with the corresponding description from the table.
I'm probably butchering my explanation here, so here's an example of what I'm looking for. Let's say this is the table:
- A Alpha
- B Bravo
- C Charlie
- D Delta
Within my layer, there's an attribute that corresponds to the "Code" in the table, and I used a SearchCursor to make a variable to choose a single record. If it says "A" in the attribute table, I want a code snippet that can see that and select "Alpha" in my exported table (or a CSV or a list that gets created from the CSV, whatever's the most painless!), so I can use that variable for replacing the generic text on a map. (I already have the text replacement code ready, but I just haven't figured out how to read the table. So, if anyone has ideas, please help!)
[EDIT: 8/4/14] Here is the code that I'm stuck on. The first line works and is simply a SearchCursor that gets me the name of an attribute from a feature class. The second line though doesn't work, which is when I'm trying to get the corresponding attribute from a table exported from a domain.
abbreviation = [row for row in arcpy.da.SearchCursor(fc, field_names="myfieldname")] fullname = arcpy.SearchCursor(r"C:\Users\Administrator\Desktop\CurrentProject\mygeodatabase.gdb\myexporteddomain", """ "Code" = '""" + str(myfieldname) + """'""")