Error msg "Name is not defined" when trying to populate a field with the shape file n

المشرف العام

Administrator
طاقم الإدارة
Error msg "Name is not defined" when trying to populate a field with the shape file n

I am trying to populate a field with corresponding file name. For example, if the file name is Route1.shp then the field value will be Route1 as well. However my code is not working. Can you please suggest a code that works? The code I used is given below, along with the error message

import arcpy, os, sys from arcpy import env arcpy.env.overwriteOutput = True env.workspace = r"C:\ABC\GIS" fc_tables = arcpy.ListFeatureClasses ("R*") for fc in fc_tables: field = "RouteName" arcpy.AddField_management (fc, field, "TEXT") for fc in fc_tables: arcpy.CalculateField_management (fc, field, str(fc), "PYTHON")And this is the error message

Runtime error Traceback (most recent call last): File "", line 2, in File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\management.py", line 3128, in CalculateField raise e ExecuteError: ERROR 000539: Error running expression: Route1.shp Traceback (most recent call last): File "", line 1, in NameError: name 'Route1' is not defined Failed to execute (CalculateField).



أكثر...
 
أعلى