What I'm trying to do is collect two .csv links and two layer identifications from the user, geocode the addresses in the .csv, and then change the data source on the identified layer in an open map to the geocoded results. The geocoding works fine, but replacing the data source doesn't work. It results in no error messages either, so I am having great difficulty tracking down the problem.
Here is a snippet of code:
mapdoc = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mapdoc, "")[0]
lyrlist = arcpy.mapping.ListLayers(mapdoc, "*", df)
for lyr in lyrlist:
if lyr.supports("DATASOURCE"):
if lyr.dataSource == cup_lyr_file:
lyr.replaceDataSource(where_to_save, "SHAPEFILE_WORKSPACE", cup_bname, "")
elif lyr.dataSource == reg_lyr_file:
lyr.replaceDataSource(where_to_save, "SHAPEFILE_WORKSPACE", reg_bname, "")
where_to_save
is the workspace collected from the user as to where the geocoded files should be saved. cup_bname
and reg_bname
are the baseNames of the geocoded shapefiles.
I am just now learning Python. With no feedback at all from the program, I'm lost as to what could be wrong.