I am creating a line shapefile from a csv in a Python (2.7) script. I am assigning an ID field from the csv to a variable and then later using it in the Calculate Field tool. The ID field originally looks like this '011947-OCT-084' which ArcGIS(10.1) does not seem to like, so I removed the '-'s and when I use that variable in the tool I get an error:
ExecuteError: ERROR 999999: Error executing function.
Expected end of statement
Failed to execute (CalculateField).
Here is my code ("temp" is the shapefile temporarily stored in in_memory):
with open(inCSV, 'rb') as input: with open(outCSV, 'wb') as output: csvwriter = csv.DictWriter(output, headers, delimiter = ',') csvwriter.writeheader() for row in csv.DictReader(input): uniqueID = row['Common_id'] newID = uniqueID.replace("-", "") arcpy.AddField_management("temp", "uniqueID", "TEXT") arcpy.CalculateField_management("temp", "uniqueID", newID) row['Common_id'] = newID csvwriter.writerow(row)
I'm not entirely sure what the cause behind this is, as I've used variables in the Calculate Tool field before without a problem. Thoughts?