XBRL and Inline XBRL (iXBRL) documents are structured electronic business reports to meet different business requirements. An XBRL document is a collection of facts that together make up a business report. Whereas, an iXBRL report is a human-readable report with tagged data embedded in it. We can easily parse an XBRL or iXBRL instance document programmatically and read objects or elements such as schema reference, context, unit, items, etc. In the previous post, we have seen how to create an XBRL document. In this article, we will learn how to parse an XBRL document in Python.
The following topics shall be covered in this article:
Python Finance Library to Parse XBRL
To parse an XBRL file or instance document, we will be using the Aspose.Finance for Python API. It allows creating XBRL instances, parsing, and validating the XBRL or iXBRL files.
The XbrlDocument class of the API represents an XBRL document containing one or more XBRL instances. An XBRL instance is an XML fragment, with the root element having an XBRL tag. The XbrlInstance class provides various methods and properties to work with XBRL instances. The InlineXbrlDocument class of the API represents an inline XBRL document.
pip install aspose-finance
Parse XBRL File in Python
We can easily load and parse an XBRL instance document by following the steps given below:
- Firstly, load an XBRL file using the XbrlDocument class.
- Next, get all the instances using the xbrl_instances.
- Then, access the desired XBRL instance from the collection.
- After that, parse the content of the XBRL instance.
- Finally, show the required data/information.
The following code sample shows how to parse an XBRL instance in Python.
Parse iXBRL File in Python
We can also parse an iXBRL document by following the steps given below:
- Firstly, load an iXBRL file using the InlineXbrlDocument class.
- Parse the content of the iXBRL document.
The following code sample shows how to parse an iXBRL in Python.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
In this article, we have learned how to parse an XBRL or iBXRL document in Python. We have also seen how to extract data from XBRL instance objects programmatically. Besides, you can learn more about Aspose.Finance for Python API using the documentation. In case of any ambiguity, please feel free to contact us on our forum.