Aug-30-2017, 12:00 AM
So based on this i would assume if you make a list and append fact.effective_numeric_value or fact.normalized_value (based on whatever you want) then you would get all the values instead of the last one. Then return the list instead of factValue.
Thank you, that sounds very logical, but as I'm completely new to Python, I would not know how I can make those changes. I will try though. I assume the code that I need to modify is below?
def factFinder( instance, namespace, label ): # Locate facts in the instance document by namespace and label, ignoring facts that have a context with a segment_element l = [] for f in instance.items: if f.qname.namespace_name.find( namespace ) and f.qname.local_name == label: l.append( f ) if not l: print('### NOT FOUND', label, type(l)) return l def printFacts( facts, indent=1, targetDate=None ): # Find the fact for the relevant target date and print it factValue = 0 for fact in facts: if targetDate==None or fact.context.period.instant == targetDate: if fact.concept.item_type==fact.concept.MONETARY_ITEM_TYPE: factValue = fact.effective_numeric_value print( indent * "\t", camelToSpaces( fact.qname.local_name ).ljust(100-indent*8), "$", '{0:>16,}'.format( factValue ) ) else: factValue = fact.normalized_value print( indent * "\t", camelToSpaces( fact.qname.local_name ).ljust(100-indent*8), factValue ) return factValue