Example #1
0
 def transform(self, posts):
     outputdata = []
     for indhold in posts:
         metadata = fetchlist_dk(str(indhold[0]), (indhold[1]))
         targeturl = metadata['dokumentUrl']
         xbrldoc_as_dict\
             = xbrlinstance_to_dict(requests.get(targeturl).content)
         xbrl_as_dk_64 = xbrldict_to_xbrl_dk_64(xbrldoc_as_dict)
         xbrl_as_dk_11 = xbrl_dk_64_to_xbrl_dk_11(xbrl_as_dk_64)
         outputdata\
             = np.append(outputdata, [xbrl_as_dk_11], axis=0)
     return outputdata
Example #2
0
def insert_regnskab(regnskab):
    session = Session()
    try:
        x = xbrl_ai.xbrlinstance_to_dict(regnskab.xbrl_file_contents)
        y = xbrl_local.xbrl_ai_dk.xbrldict_to_xbrl_dk_64(x)
        financial_statement = initialize_financial_statement(regnskab)
        session.add(financial_statement)


        for key, val in y.items():
            if key in ('{http://www.xbrl.org/2003/linkbase}schemaRef',
                       '@{http://www.w3.org/2001/XMLSchema-instance}schemaLocation'):
                continue
            fieldName, startDate, endDate = key[0], key[1], key[2]
            label_typed_id, koncern, xbrl_unit = key[3], key[4], key[5]
            fieldValue, unit, decimals, dimension_list = val

            if xbrl_unit is not None:
                xbrl_unit = str(xbrl_unit)
            if unit is not None:
                unit = str(unit)
            if fieldValue is not None:
                fieldValue = str(fieldValue)
            if decimals is not None:
                decimals = str(decimals)
            assert(xbrl_unit == unit)

            dimensions = label_typed_id
            # keys in row:
            # Name,Value,contextRef,unitRef,Dec,Prec,Lang,EntityIdentifier,Start,End/Instant,Dimensions
            cvrnummer = regnskab.cvrnummer

            financial_statement.financial_statement_entries.append(
                FinancialStatementEntry(
                    fieldName=fieldName, fieldValue=fieldValue,
                    decimals=decimals,
                    cvrnummer=cvrnummer,
                    startDate=startDate, endDate=endDate,
                    dimensions=dimensions,
                    unitIdXbrl=xbrl_unit,
                    koncern=koncern
                )
            )

        session.commit()
    except Exception:
        session.rollback()
        raise
    finally:
        session.close()
    return
Example #3
0
from xbrl_ai import xbrlinstance_to_dict
from xbrl_local.xbrl_ai_dk import fetchlist_dk, xbrldict_to_xbrl_dk_64, xbrl_dk_64_to_xbrl_dk_11, xbrl_to_dk_11, scanscroll_fetchlist_dk
"""
Step by step
"""

# Step 1:
#linkdata = fetchlist_dk('30004000', '2015-10-31')
#linkdata = fetchlist_dk('61056416', '2015-10-31')
#linkdata = fetchlist_dk('36714565', date='2016-12-31', reports='ALL', style='dict')
linkdata = fetchlist_dk('11964346', '2016-08-31')
linkdata = fetchlist_dk('33764006', '2018-02-28')
targeturl = linkdata['dokumentUrl']

# Step 2:
xbrldoc_as_dict = xbrlinstance_to_dict(requests.get(targeturl).content)

# Step 3:
xbrl_as_dk_64 = xbrldict_to_xbrl_dk_64(xbrldoc_as_dict)

# Step 4:
xbrl_as_dk_11 = xbrl_dk_64_to_xbrl_dk_11(xbrl_as_dk_64, True)
"""
USAGE OF TRANSFORMER
"""

# Step 1 - 4 for all 4 instances by usage of Transformer
input_data = [['30004000', '2015-10-31'], ['61056416', '2015-10-31'],
              ['36714565', '2016-12-31'], ['11964346', '2016-08-31']]

get_data = xbrl_to_dk_11()
Example #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 25 21:42:35 2018

@author: niels-peter
"""

__title__ = 'test_xbrl_ai_be'
__version__ = '0.0.1'
__author__ = 'Niels-Peter Rønmos'

import requests
from xbrl_ai import xbrlinstance_to_dict, xbrldict_to_xbrl_54

file = open('201702100243.xbrl','r')


file_indhold = file.read()

xbrl = xbrlinstance_to_dict(file_indhold)
xbrl_as_54 = xbrldict_to_xbrl_54(xbrl)