I have a simple script which uses the Append gp tool with the option to update existing records (upsert). I am trying to access derived output parameters "appended_row_count" and "updated_row_count". Are these elements of the list? I am getting The index 1 is out of range error.
When I check the Get count gp tool output parameter ("row_count") it is being accessed as the first element of the list. It does not seem to be working for me for the other tool.
How to get these two long integer values in the py script?
Thanks.
not sure I follow, but anyway, the first element of a python list is 0, if index 1 is being queried and doesn't exist, that is why you are getting the error
another possibility is that a list is being returned (index 0) which may contain more than 1 element eg 0 and 1) so you would have to get the list then index into it
Yeah, I put the question is a quite complicated way. Look at the screenshot.
the code is:
loaded = arcpy.management.Append(
inputs=inputLayer,
target=destTable,
schema_type="NO_TEST",
field_mapping=None,
subtype="",
expression="",
match_fields="keyfield keyfield",
update_geometry="UPDATE_GEOMETRY"
)
it appends the data. If you look at the tool description in the section of the Derived Output you see three parameters. I do not know how to get a second and third long integer value. When printing "loaded" I get only path to target feature class.
Sorry, my fault. I have Pro 3.2. Three parameters in the Append tool are available in version 3.3..
You can get the output like this,
# Print derived output and messages
print("Derived Output (Target Layer):", append[0]) # The first element is the target layer path
print("Messages:")
for message in append.getMessages().splitlines():
print(message)
Whoops, hit enter too quickly. Updated to use the variable you set for the append function,
# Print derived output and messages
print("Derived Output (Target Layer):", loaded[0]) # The first element is the target layer path
print("Messages:")
for message in lloaded.getMessages().splitlines():
print(message)