After insert lower() there's nothing written in the field? What's wrong?
# Process: Feld berechnen arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", "\"U:\\rips\\images\\tk50\\tk\" & ([BLATT_NR].lower()) & \"co\" & \"*.*\"", "VB", "")
The VBScript function is LCase, as in
LCase("STRING")
I really like splitting long Python statements on multiple lines; the interpreter ignores the newline if you are inside ( 😞
# VB Parser arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", ("\"U:\\rips\\images\\tk50\\tk\" & LCASE([BLATT_NR])" "& \"co\" & \"*.*\"", "VB")' # Python Parser (better, and will run in arcpy 64)! arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", ("\"U:\\rips\\images\\tk50\\tk" "{}\\co\\*.*\".format(!BLATT_NR!).lower()"), "PYTHON")
This is for the model ok:
"U:\\rips\\images\\tk50\\" + !BLATT_NR!.lower() + "co*.*"
Result export to python:
# Process: Feld berechnen arcpy.CalculateField_management(Orthos_Nummern_Layer, "Pfad", "\"U:\\\\rips\\\\images\\\\tk50\\\\\" + !BLATT_NR!.lower() + \"co*.* \"", "PYTHON", "")
No field calculate?
Tried this:
arcpy.CalculateField_management(Orthos_Nummern_Layer, "Pfad", "\"U:\\rips\\images\\tk50\\\" + !BLATT_NR!.lower() + \"co*.* \"", "PYTHON", "")
What I need:
"U:\\rips\\images\\tk50\\l6518co.*"
Thanks for your answers, but I can't follow them or they don't work.
I try now to get a model to work and then export to python.
!BLATT_NR!.lower()
This works in the model
"U:\\rips\\images\\tk50\\" & !BLATT_NR!.lower() & "co.*"
For this I get a error message?
ERROR 000539: Error running expression: "U:\\rips\\images\\tk50\\" & "L6518".lower() & "co.*"
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'str' and 'str'
What's the problem?
do it manually first then copy the syntax from the field calculator expression, fields in python are enclosed in ! ! marks, if that makes a difference
Untested:
Likely what will work:
arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", r"U:\rips\images\tk50\tk\\" + ([BLATT_NR].lower()) + "co\\" + "*.*", "PYTHON_9.3", "")
Or from your original code:
arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", "\"U:\\rips\\images\\tk50\\tk\" + ([BLATT_NR].lower()) + \"co\" + \"*.*\"", "PYTHON_9.3", "")
I don't believe ".lower()" can be used with the VB parser. That is Python.
Thanks for the answer. The field calculation work without lower() function, so don't care about all the funny text around.
This must be the problem. Or can`t you lower the expression of a field string in this manner?
I'd put the calculation expression in a variable and check that. It kind of looks like your quotation marks are off, but honestly it's a bit hard to follow all that.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.