Hello,
I'm writing for some assistance in troubleshooting converting an old Model from VB script to Python.
The specific area giving me trouble is a Calculate Field Expression
here's what I started with:
=[AREA_CODE] & Replace ([BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER], " ", "")
this gave error00539 'Replace' is not defined
Here's a couple things I attempted:
!AREA_CODE! & Replace (!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!, " ", "")
^same error code
!AREA_CODE! + replace (!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!, " ", "")
^same error code
!AREA_CODE! + (!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!, " ", "")
^error 00539-TypeError: can only concatenate str (not "tuple") to str
!AREA_CODE! + tuple(!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!, " ", "")
^error 00539-TypeError: tuple expected at most 1 arguments, got 3
!AREA_CODE! + [tuple(!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!, " ", "")]
^error 00539-Syntax error: invalid syntax
I'm at a bit of a loss as to what to try next
please let me know what you think
Sincerely,
Christopher
Solved! Go to Solution.
Assuming that you want to concatenate the two fields and remove spaces in the longer field name. "str"ing both fields in case a number to text conversion is necessary.
str(!AREA_CODE!) + str(!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!).replace(" ", "")
I am thinking the REPLACE part is doing nothing but maybe convert a numeric field to a string The str() will pretty much turn anything into a string, so this seems like it would be safe.
str(!AREA_CODE!) + str(!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!)
Hello, thank you much!
Assuming that you want to concatenate the two fields and remove spaces in the longer field name. "str"ing both fields in case a number to text conversion is necessary.
str(!AREA_CODE!) + str(!BIDDER_PERCENTAGES_TABLE_SELECT_BLOCK_NUMBER!).replace(" ", "")
Hello, Thank You much!