Skip to main content
Hello,

 

 

I have a Shutdown Python script that is working well overall. I am having an issue when it tries to use the Esri Calculate Field tool. The string that is used to calcualte the field comes from a published parameter in the workspace. The only way that I have been able to get it to work is to put double quotes aroung the input value on the FME Server page. Otherwise it fails and will not update the field.

 

 

Is it possible to convert  this:

 

 Enter_the_Image_Name = fme.macroValueso'Image_Name'] so that when I run this:

 

 arcpy.CalculateField_management(Imagery_Mosaic_Layer, "Image_Name",Enter_the_Image_Name, "Python", "") 

 

that Enter_the_Image_Name is seen as a string? Currently the process fails if I don't use double quotes.

 

 

Thanks,

 

 

Vince
Hi,

 

 

I'm not quite sure I understand, but there are two things to try, depending on what the actual challenge is:

 

 

1) Casting Enter_the_Image_Name explicitely as a string:

 

arcpy.CalculateField_management(Imagery_Mosaic_Layer, "Image_Name",str(Enter_the_Image_Name), "Python", "")

 

2) Manually adding the quotes:

 

Enter_the_Image_Name = '"' + str(fme.macroValuesr'Image_Name']) + '"'

 

Alternative 1 will make sure that a string (with our without double quotes) is sent to arcpy, where as alternative 2 will send a string with doubles quotes.

 

 

Does any of this help?

 

 

David
David,

 

Number 2 worked. I tried number 1 earlier but that didn't work. I was able to get it to work by creating another variable and doing this:

 

 

Enter_the_Image_Name = fme.macroValuesu'Image_Name']

 

CalcName = '"' + Enter_the_Image_Name  + '"'

 

 

and then using CalcName in the in CalculateField but I'm going top use what you posted since it's a better solution.

 

 

Thanks for your help,

 

 

Vince

 

 

 


Hi,

 

 

there is really no practical difference between your and my solution, so feel free to use whichever you feel is the easiest to maintain :-)

 

 

David

Reply