I'm using the jira-python library to query data from jira. I'm getting back the data I need from jira but processing the data has been giving me issues.
I'm looking to count the occurrences of all components returned from my query. For example, my query will return the results:
Component A
Component B
Component A
Component C
The results I'm looking for is something like:
Component A, 2
Component B, 1
Component C, 1
Here is a snippet of my current code:
search = 'jira query'
issues = jira.search_issues(search, maxResults=100)
for issue in issues:
[c.name for c in issue.fields.components]
From here I have tried to count and sum c.name
sum(1 for c.name in issue.fields.components)
However this wouldn't produce the correct results as I would get results like counting the number of character occurrences for each result.
Any insight/help would be greatly appreciated
Pass the list/generator expression of names to a
collections.Counter
object.