BuffetCode / edinet_xbrl

A Python xbrl file downloader and parser for EDINET

Home Page:https://www.buffett-code.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_valueオブジェクトがない、とエラーが出る

opened this issue · comments

以下、原因がわからず困っております。
.get_valueを除いて実行するとNoneが格納されます。

【実行】
from edinet_xbrl.edinet_xbrl_parser import EdinetXbrlParser

"""

init parser

parser = EdinetXbrlParser()

parse xbrl file and get data container

xbrl_file_path = ("dataset/6072_jpcrp030000-asr-001_E27059-000_2014-03-31_01_2014-06-27.xbrl")
edinet_xbrl_object = parser.parse_file(xbrl_file_path)

例えば、該当年度の総資産を取ってみる

key = "jppfs_cor:Assets"
context_ref = "CurrentYearInstant"
current_year_assets = edinet_xbrl_object.get_data_by_context_ref(key, context_ref).get_value()

【エラー】
AttributeError Traceback (most recent call last)
in ()
12 key = "jppfs_cor:Assets"
13 context_ref = "CurrentYearInstant"
---> 14 current_year_assets = edinet_xbrl_object.get_data_by_context_ref(key, context_ref).get_value()

AttributeError: 'NoneType' object has no attribute 'get_value'
"""

@UMVUE おそらく、指定している keycontext_ref のペアが良くないのではないでしょうか

https://github.com/BuffetCode/edinet_xbrl/blob/master/edinet_xbrl/edinet_xbrl_object.py#L69-L74

filterで何も引っかからなかった場合、ここで明示的に None を返しています。

xbrl_object には、 has_keyget_keys というmethodも作ってあるので、それを使って事前に値の有無を確認するといいかもしれません。

https://github.com/BuffetCode/edinet_xbrl/blob/master/edinet_xbrl/edinet_xbrl_object.py#L76-L80