kanedata / ixbrl-parse

A python library for getting useful data out of ixbrl files.
https://ixbrl-parse.readthedocs.io/
MIT License
64 stars 26 forks source link

'NoneType' object has no attribute 'attrs' #7

Closed Besarion-95 closed 5 years ago

Besarion-95 commented 5 years ago

Hi there Ive been trying to fix the issue. When i ran some tests i came across this error: AttributeError: 'NoneType' object has no attribute 'attrs'

in the following section: ixbrl-parse-master\ixbrlparse\core.py 22(line) for k in self.soup.find('html').attrs: 24(line) if k.startswith("xmlns") or ":" in k: 25(line) self.namespaces[k] = self.soup.find('html')[k].split(" ")

Tried using a try-except to avoid NoneType exception: but that hasnt worked.

Ill let you know if i find a fix.

Besarion-95 commented 5 years ago

This this the company causing the issue: 06064460

What i think it is is because the tags Arent link:schemaref but just schemaref

as well as the resource tag is reserouces instead of ix:resources.

Ive tried using the try:, exception: but that hasnt worked.

    try:
        self.schema = self.soup.find('link:schemaref').get('xlink:href')
        self.namespaces = {}
    except:
        self.schema = self.soup.find('schemaref').get('xlink:href')
        self.namespaces = {}

Once I changed: <schemaRef xlink:href=> To <link:schemaRef xlink:href=>

and resources to ix:resources

The program runs no issue however, the JSON doesnt get out putted. Could it be because its referencing: http://www.xbrl.org/2003/instance which seems to suggest the reference should be: http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd

So guess its a different kind of ixbrl?

drkane commented 5 years ago

Thanks for sharing the issue - I've added a test case for this type of account. Looks like I might need to rethink how the XML parsing works. They've used a different (but presumably valid) way of specifying the namespace for the XML tags.

drkane commented 5 years ago

I've reworked the code to use a different parser - let me know if it fixes your issue @Besarion-95

Besarion-95 commented 5 years ago

Hi there drkane,

Thank you that has fixed the issue.