Arek-
Thank you for the reply. Creating the Feature Layer and doing the Join seems to work just fine without any hold-up or lagging.... This is being done outside of ArcMap outside of an Edit Session... My intention is to have this done automatically at night and the only way I have figured out to do it is to have a Python Script and run a schedule task using the Windows Task Scheduler.
Forgive me - but I am still really new to Python and not sure how to use or write indexes and python dictionaries......I have done some (very little reading on it).....
Any ideas????
Thank you
Here is an example of some code I use all the time for getting values from one table to another without needing to join them. I wrote this because I was frustrated by the amount of time it took to use the "join and calculate" method. This is a hundred times faster because it uses dictionaries with update cursors.The parameters are just the target table (I called it source_table below), a field with common values in both tables, a list of fields to be updated, the table with the desired values, the join field, then the fields that contain the values. Below is the 10.0 code, I also have another version for 10.1 which is a little faster. Let me know if you want that. import sys, traceback, arcpy, os from os import path as p def AttributeUpdate(source_table, in_field, update_fields, join_table, join_key, join_values): try: """ Updates fields from one table to user defined fields in another table""" # Check input parameters if not arcpy.Exists(source_table): print source_table + ' not found!\nPlease verify that full path of table exists' sys.exit() if not arcpy.Exists(join_table): print join_table + ' not found!\nPlease verify that full path of table exists' sys.exit() if in_field not in [f.name for f in arcpy.ListFields(source_table)]: print in_field + ' not found in ' + p.basename(source_table) sys.exit() if join_key not in [f.name for f in arcpy.ListFields(join_table)]: print join_key + ' not found in ' + p.basename(join_table) sys.exit() for fld in update_fields: if fld not in [f.name for f in arcpy.ListFields(source_table)]: print fld + ' not found in ' + p.basename(source_table) print 'Please verify that field names match in ' + p.basename(source_table) sys.exit() for fldb in join_values: if fldb not in [f.name for f in arcpy.ListFields(join_table)]: print fldb + ' not found in ' + p.basename(join_table) print 'Please verify that field names match in ' + p.basename(join_table) sys.exit() if not type(join_values) == list: join_values = list(join_values) if not type(update_fields) == list: update_fields = list(update_fields) # Make sure there is matching number of join and update fields update_dict = {} if len(update_fields) == len(join_values): for i in range(len(update_fields)): update_dict[join_values] = update_fields for k,v in update_dict.iteritems(): # Create Dictionary path_dict = {} srows = arcpy.SearchCursor(join_table) for srow in srows: keyrow = srow.getValue(join_key) valrow = srow.getValue(k) path_dict[keyrow] = valrow # Update Cursor urows = arcpy.UpdateCursor(source_table) for row in urows: upkey = row.getValue(in_field) try: if upkey in path_dict: row.setValue(v, path_dict[upkey]) urows.updateRow(row) except: pass # skip nulls print '\'%s\' field in "%s" updated successfully' %(v, p.basename(source_table)) del row, urows, srow, srows else: print 'ERROR: Number of update fields and value fields does not match' except: print '\nERROR in AttributeUpdate Function.\nPlease Check input parameters and try again.' if __name__ == '__main__': shp = r'C:\IGIC\Advanced\Functions\DATA\Iowa_Co.shp' dbf = r'C:\IGIC\Advanced\Functions\DATA\Census_2000.dbf' # Attribute Update test up_fields = ['POP2000','Perc_Urb','Perc_Rur'] jn_fields = ['POP2000','PCT_URB_00','PCT_RUR_00'] AttributeUpdate(shp,'FIPS',up_fields,dbf,'FIPS',jn_fields)
I usually just import this function into other scripts. I have called the script MemoryTableTools. Here is an example of how you can do that:import MemoryTableTools shp = r'C:\IGIC\Advanced\Functions\DATA\Iowa_Co.shp' dbf = r'C:\IGIC\Advanced\Functions\DATA\Census_2000.dbf' up_fields = ['POP2000','Perc_Urb','Perc_Rur'] jn_fields = ['POP2000','PCT_URB_00','PCT_RUR_00'] MemoryTableTools.AttributeUpdate(shp,'FIPS',up_fields,dbf,'FIPS',jn_fields)