Getting an error while trying to script it, specifically "Cannot use VB for services." Snippet and VB code block as follows:
Raw block (works within ArcMap): "\ftp\raw\YYYYMMDD\Files\Charles" +[NAME]+".ntf"
Snippet:
date = '"20160207"'
arcpy.CalculateField_management(outShp, "Link", '"\\\\ftp\\raw\\"' + date + '"files"' + "[NAME]"+ '".shp"', "VB", "")
Not sure what the issue is, somehow need to be able to insert the date and have it syntactically be correct (in either VB or python).
I didn't explain very well I have a column that contains a portion that is part of the hyperlink, so need to concatenate A column to the end of B column (with the partial path) to complete the link
Answer
I hope I understood your problem sufficiently. As far as I got it, I would try the following:
# predefine the constant parts of your expression using a variable:
constant = "\ftp\raw\YYYYMMDD\Files\Charles"
nameVar = "yourobject.Name"
# use the built in function .format for setting up the expression for your arcpy.CaculateField_management function:
expression = """{0}\{1}files{2}.shp""".format(constant, date, nameVar)
arcpy.AddFieldDelimiters("yourworkspace", expression)
# then simply use the expression variable in your arcpy function:
arcpy.CalculateField_management(outShp, "Link", expression)
If you want to put togehter paths and file names, you could look into the os.walk
or arcpy.da.walk
tool. Also, should there remain problems with the SQL-expression, try the arcpy.AddFieldDelimiters()
tool. Hope this helps.
Edit 9th of February 2016: Since you're saying that your syntax is working within the main tool but not in the script, I suggest checking your paths. Avoid gaps and special characters. Also try checking the "store relative path names" under the general tab of your script properties. Have you tried the arcpy.AddFieldDelimiters()
function yet? Good luck.
No comments:
Post a Comment