-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to get textual labels? #66
Comments
Labels are stored in the label linkbase the taxonomy schema imports. An example: first_label = fact.concept.labels[0] Another complete example that also extracts the labels of the members: logging.basicConfig(level=logging.INFO)
cache: HttpCache = HttpCache('./cache')
cache.set_headers({'From': '[email protected]', 'User-Agent': 'py-xbrl/2.0.7'})
xbrlParser = XbrlParser(cache)
inst: XbrlInstance = xbrlParser.parse_instance(
'https://www.sec.gov/Archives/edgar/data/320193/000032019321000065/aapl-20210626.htm')
for fact in inst.facts:
if fact.concept.name == 'RevenueFromContractWithCustomerExcludingAssessedTax':
label: str = fact.concept.labels[0]
segments: list = fact.context.segments
pretty_str: str = f"{label}: {fact.value}"
for segment in segments:
pretty_str += f" ({segment.dimension}, {segment.member.labels[0]})"
print(pretty_str) This will return the following output:
Does this answer your question? :) |
This actually does answer my question. I had found a very round about way of doing it which did not work with the old file structure. As a follow up though... is there any way to select for a table? For example the above shows a consolidated statement of operations. I've managed to find where that is specified in the taxonomy, but i am lost as to how i might find the net sales corresponding with that table. edit: |
This might help, see extracted labels |
The #21 was useful in getting the relevant concept names, but is there any way to connect those to individual or specific inst.facts? I was not able to find any arc.to_locator objects which corresponded with anything in the facts object beside the concept.xml_id, but this is not specific enough to select certain facts. |
Currently the libary does not combine the information from the presentation linkbase and the instance document. However I would like to introduce this in the future. I am planning to introduce a method But a full implementation of this is also quite challenging. Taxonomies can override each other and can prohibit the use of certain relationships. If you really want to implement it properly, you would have to concider overriding and inheritance of hierarchies within multiple imported taxonomies.. Also keep in mind that there are multiple types of taxonomies (calculation, presentation, definition, reference, label, formular ...). If you want to get an introduction about XBRL Taxonomies you can read my blog entry "What is XBRL?" section "2.2 Taxonomy Linkbases". But this blog entry does not cover inheritance of taxonomies. For a deep dive into XBRL I can only recommend the book "XBRL for Interactive Data" (978-3-642-01437-6). |
That would be great if we could do |
@manusimidt Manuel, i know you are busy (i think you mentioned that you continue the studies) but did you have near future plans on |
To be honest I haven't started with this feature until now, because I thought that other features had higher priority. Since the |
@manusimidt got it, that makes perfect sense. |
Is there any way to retrieve the textual label corresponding to a fact when it is in a table as follows?
In the above table, under Net Sales, Products, Services and total net sales each correspond with tag :
us-gaap:RevenueFromContractWithCustomerExcludingAssessedTax
.I was able to parse out the member labels to retrieve tags like
us-gaap:ServiceMember
.What I would really like to do is to find the relavent table labels of
Products
,Services
, andTotal set sales
. As far as I can tell these are only in the html portion of xbrl docs.Is there already a way to access these labels, if not how might I go about it?
The text was updated successfully, but these errors were encountered: