Read XBRL Files in Python

Structured electronic business reports are made up of XBRL documents and Inline XBRL (iXBRL) documents. In XBRL, business reports are collections of facts. Alternatively, an iXBRL report is human-readable and contains tagged data. Programmatically, we can read XBRL or iXBRL instance documents and retrieve schema references, contexts, items, etc. In this article, we will learn how to read XBRL files in Python.

The following topics shall be covered in this article:

  1. Python XBRL Reader to Read XBRL
  2. Read XBRL File
  3. Read iXBRL File

Python XBRL Reader to Read XBRL

For reading XBRL files or instance documents, we will be using the Aspose.Finance for Python API. It allows creating XBRL instance documents, parsing, and validating the XBRL or iXBRL files.

The API provides the XbrlDocument class that represents an XBRL document containing one or more XBRL instances. The XbrlInstance class provides various methods and properties to work with XBRL instances. We have the InlineXbrlDocument class that represents an inline XBRL document.

Please either download the package or install the API from PyPI using the following pip command in the console:

pip install aspose-finance

Read XBRL Files using Python

We can easily load and read an XBRL instance document by following the steps given below:

  1. Firstly, load an XBRL file using the XbrlDocument class.
  2. Next, get all the instances using the xbrl_instances.
  3. Then, access the desired XBRL instance by accessing using its index from the collection.
  4. After that, read the content of the XBRL instance.
  5. Finally, show the required data/information.

The following code sample shows how to read an XBRL file in Python.

Read iXBRL Files in Python

We can also read an iXBRL document by following the steps given below:

  1. Firstly, load an iXBRL file using the InlineXbrlDocument class.
  2. Read the content of the iXBRL document.

The following code sample shows how to read an iXBRL file in Python.

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to read XBRL files 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 documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also