Timeline for ArcPy Calculate Field Management with Variable
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 7, 2018 at 17:32 | comment | added | Matt A. | @Tom I tried running the code in the Code Block of the Field Calculator and got a similar error about a missing or incorrect parameter. The datatypes for all the fields I'm using in the code is "Double". As far as the print statements, I was able to successfully print the the Table name and the DemoField name. I'm not sure how I would print the expression, unless I assigned it to a variable. | |
May 7, 2018 at 16:27 | comment | added | Tom | @MattA., what are the datatypes of each of your fields? | |
May 7, 2018 at 16:18 | comment | added | Tom | Thanks, Bjorn. I always get a list of names with list comprehension, so I overlooked that. It's fixed. @MattA., it's supposed to be outside the quotes. Otherwise, you're simply looking for a field that matches your variable name rather than the value held by the variable. | |
May 7, 2018 at 16:16 | history | edited | Tom | CC BY-SA 4.0 |
added 5 characters in body
|
May 7, 2018 at 16:14 | comment | added | Matt A. |
I've tried both "(!{}! * !TractPercent!) / !BufferPOP!".format(DemoField) and "(!{}! * !TractPercent!) / !BufferPOP!".format(DemoField.name) , but I am still getting the same errors. I looked at the data types associated with the CalculateField_management , (pro.arcgis.com/en/pro-app/tool-reference/data-management/…) but didn't see anything that stood out. Except for maybe that .format(DemoField) is outside the quotes
|
|
May 7, 2018 at 15:44 | comment | added | Bjorn |
Shouldn't it be DemoField.name ?
|
|
May 7, 2018 at 15:32 | history | edited | Midavalo♦ | CC BY-SA 4.0 |
Fixed code formatting
|
May 7, 2018 at 15:26 | history | answered | Tom | CC BY-SA 4.0 |