简体   繁体   English

如何使用 Arelle 的 Python API 仅从 XBRL 文件中提取财务报表?

[英]How to extract financial statements only from XBRL files using Arelle's Python API?

Somehow, with the broken documentation on Arelle's python API as of date, I managed to make the API work and successfully load an XBRL file.不知何故,到目前为止, Arelle 的 python API 文档已损坏,我设法使 API 工作并成功加载了一个 XBRL 文件。

Anyways, my question is:无论如何,我的问题是:

How do I extract only the STATEMENTS from the XBRL file?如何仅从 XBRL 文件中提取 STATEMENTS?

Below is a screenshot from Arelle's Windows App.下面是来自 Arelle 的 Windows 应用程序的屏幕截图。

URL used in this example: https://www.sec.gov/Archives/edgar/data/101984/000010198416000062/ueic-20151231.xml本例中使用的 URL: https : //www.sec.gov/Archives/edgar/data/101984/000010198416000062/ueic-20151231.xml

图形用户界面

I tried experimenting with the API and here's my code我尝试使用 API 进行试验,这是我的代码

from arelle import Cntlr

xbrl = Cntlr.Cntlr().modelManager.load('https://www.sec.gov/Archives/edgar/data/101984/000010198416000062/ueic-20151231.xml')

for fact in xbrl.facts:
   print(fact)

but after executing this snippet, I'm bombarded with these:但是在执行这个片段之后,我被这些轰炸了:

PyCharm 命令行界面

I tried getting the keys available per modelFact and its a mixture between contextRef , id , decimals and unitRef which is not helpful from what I want to extract.我试图让每间可用按键modelFact之间的混合contextRefiddecimalsunitRef这是不是从我想提取有用的。 With no documentation to help further with this, I'm at a loss here.没有文档可以进一步帮助我解决这个问题,我在这里不知所措。 Can someone enlighten me on how to achieve extracting only the statements?有人可以启发我如何实现只提取语句吗?

I am doing something similar and have so far had some progress which I can share:我正在做类似的事情,到目前为止已经取得了一些可以分享的进展:

Going through the python code files of arelle you can detect which properties you can access for the different classes such as ModelFact, ModelContext, ModelUnit etc.通过 arelle 的 python 代码文件,您可以检测可以访问不同类(例如 ModelFact、ModelContext、ModelUnit 等)的哪些属性。

To extract the individual data, you can for example put them in a panda dataframe as follows:要提取单个数据,您可以将它们放入熊猫数据框中,如下所示:

factData=pd.DataFrame(data=[(fact.concept.qname,
                           fact.value,
                           fact.isNumeric,
                           fact.contextID,
                           fact.context.isStartEndPeriod,
                           fact.context.isInstantPeriod,
                           fact.context.isForeverPeriod,
                           fact.context.startDatetime,
                           fact.context.endDatetime,
                           fact.unitID) for fact in xbrl.facts])

Now it is easier to work with all the data, filter those that you want to use etc. If you want to reproduce the statements tables, you will also need to incorporate the links for each of the facts and than order and sort, but I haven't gotten this far either.现在可以更轻松地处理所有数据,过滤您想要使用的数据等。如果您想重现报表表,您还需要合并每个事实的链接,而不是排序和排序,但我也没有走到这一步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM