Getting a count of the rows and having the output in a table using model builder and python

472
2
09-19-2019 02:41 PM
TilottamaGhosh
New Contributor III

Hi,

I am running a model, and in the end I need to get a count of the rows, 'collect values' (model builder tool) and 'calculate values' (model builder tool) and get the output in a table. I am unable to do this. I am using the python code from this post arcgis desktop - Using ModeBuilder to populate a table with the feature count of multiple feature cl... , but running into an error with the python code block -

 def sum_counts(counts):         if counts.find(';') == -1:             if counts <> '#': return int(counts)             else: return 0         else:              return sum(map(int, counts.split(';')))

What am I doing wrong? How will I achieve getting a count of the rows and putting the output in a table.

Thanks,

Tilottama

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

code was formatted improperly.

/blogs/dan_patterson/2016/08/14/script-formatting 

What was the actual error message?

def sum_counts(counts):
    if counts.find(';') == -1:
        if counts != '#':
            return int(counts)
        else:
            return 0
    else:
        return sum(map(int, counts.split(';')))
0 Kudos
TilottamaGhosh
New Contributor III

Hi Dan,

Thanks for your reply. I was able to run the model using Summary Statistics and now have a different question. I will put the question in a separate post and will look forward to a reply.

Thanks,

Tilo

0 Kudos