Datensatz
Nachfolgend wird der Abschluss respektive die Bilanz behandelt, die als DiFin-Datensatz an die Bankleitzahl der Bank oder Sparkasse übermittelt wird – und wie diese Daten aus dem DiFin-Datensatz ausgelesen werden.
Es ist davon auszugehen, dass ein nachfolgendes Mapping der eingelesenen Daten auf die Zielpositionen des Banksystems aus den bisher eingegangenen Daten (bspw. als PDF-Datei oder papierhaft) bereits vorliegt.
Nachfolgende Code-Beispiele sind in der Programmiersprache python verfasst und konsekutiv aufgebaut. Für eine performanteren Code sowie eine „Übersetzung“ in andere Programmiersprachen wird auf die bestehenden und verfügbaren Code-Generierer und -„Übersetzer“ verwiesen (ChatGPT, Granite, Codegemma, etc.).
Taxonomien
Die xbrl-Taxonomien hält der xbrl-Verein vor.
Diese sind herunterzuladen und zu entpacken.
import requests
import zipfile
import io
URL66 = "https://www.xbrl.de/german-gaap-taxonomy-v6.6-2022-05-02.zip"
request66 = requests.get(URL66)
zip66 = zipfile.ZipFile(io.BytesIO(request66.content))
zip66.extractall("/Users/sandromarx/Desktop/Py/xbrl/de/taxonomies")
Rahmen-Daten
xbrl-Taxonomie
Auslesen der Informationen aus der xbrl-Taxonomie.
from xml.dom import minidom as md
import pandas as pd
import pathlib
label = []
labelArc = []
labelArcOP = []
presentationLabel = []
presentationLabelOP = []
presentationLabelOrder = []
# label-Linkbase
dom = md.parse('[...]/xbrl/de-gcd-2022-05-02/de-gcd-2022-05-02-label-de.xml')
elements = dom.getElementsByTagName('label')
elementsArc = dom.getElementsByTagName('labelArc')
for element in elements:
elementValue = element.attributes['xlink:label'].value
elementValueCore = elementValue.removeprefix('label_de-gcd_genInfo.')
label.append(elementValueCore)
for elementArcFrom in elementsArc:
elementArcFromValue = elementArcFrom.attributes['xlink:from'].value
elementArcFromValueCore = elementArcFromValue.removeprefix('de-gcd_genInfo.')
elementArcLabelValue = elementArcFrom.attributes['xlink:to'].value
elementArcLabelValueCore = elementArcLabelValue.removeprefix('label_de-gcd_genInfo.')
elementArcFromValueCore)
labelArc.append(elementArcLabelValueCore)
labelArcOP.append(elementArcFromValueCore)
# presentation-Linkbase
dom = md.parse('[...]/xbrl/de-gcd-2022-05-02/de-gcd-2022-05-02-presentation.xml')
presentationsArc = dom.getElementsByTagName('presentationArc')
for presentationArcLabelAndOrder in presentationsArc:
presentationArcLabelOnly = presentationArcLabelAndOrder.attributes['xlink:from'].value
presentationArcLabelOnlyCore = presentationArcLabelOnly.removeprefix('de-gcd_genInfo.')
presentationArcLabelOrderOnly = presentationArcLabelAndOrder.attributes['order'].value
presentationArcLabel = presentationArcLabelAndOrder.attributes['xlink:to'].value
presentationArcLabelCore = presentationArcLabel.removeprefix('de-gcd_genInfo.')
presentationLabel.append(presentationArcLabelCore)
presentationLabelOP.append(presentationArcLabelOnlyCore)
presentationLabelOrder.append(presentationArcLabelOrderOnly)
# dataframes
dfArc = pd.DataFrame({'label': labelArc,'labelOP': labelArcOP})
dfPresentation = pd.DataFrame({'label': presentationLabel,'labelOP': presentationLabelOP, 'labelOrder': presentationLabelOrder})
dfTotal = pd.concat([dfArc, dfPresentation], axis=0, ignore_index=True, sort=True)
dfTotal.sort_values(['label'], ascending=[True])
# speichern
filepath = pathlib.Path('[...]/gcd.csv')
filepath.parent.mkdir(parents=True, exist_ok=True)
dfTotal.to_csv(filepath)
Instanzdatei
Auslesen der Informationen aus der Instanzdatei und verknüpfen mit den Taxonomie-Daten.
import os
import pathlib
import xml.etree.ElementTree as ET
import pandas as pd
import numpy as np
# parsen
instance = ET.parse('[...]/instances/MusterholzGmbH/wd/FA/96429000_1002954034_VjNein_KnJa_MlNein.xml')
root = instance.getroot()
# BLZ, Name der Bank / Sparkasse, Kundennummer, Firma
blzCheck = []
blz = []
for blzChk in root.findall('.//Empfaenger/Identifikationen/Identifikation/Art'):
blzCheck.append(str(blzChk.text))
for blzItem in root.findall('.//Empfaenger/Identifikationen/Identifikation/Wert'):
blz.append(blzItem.text)
name = []
for nameItem in root.findall('.//Empfaenger/NameBank'):
nameItemFinal = nameItem.text
name.append(nameItemFinal)
kdrCheck = []
for kdrChk in root.findall('.//Kunde/Identifikationen/Identifikation/Art'):
kdrCheck.append(kdrChk.text)
kdrCheckFinal = kdrCheck[0]
kundenNummer = []
for kdrItem in root.findall('.//Kunde/Identifikationen/Identifikation/Wert'):
kundenNummer.append(kdrItem.text)
kundenNummerFinal = kundenNummer[0]
firma = []
for fir in root.findall('.//Kunde/Name'):
firFinal = fir.text
firma.append(firFinal)
# Taxonomie, Abschlussstichtag, -art, Konsolidierungskreis, Kontenrahmen, Identität
taxonomie = []
for tax in root.findall('.//Taxonomie'):
taxonomieFinal = tax.text
taxonomie.append(taxonomieFinal)
abschlussStichtag = []
for stichtag in root.findall('.//Bilanz/Abschlussstichtag'):
stichtagFinal = stichtag.text
abschlussStichtag.append(stichtagFinal)
abschlussArt = []
for art in root.findall('.//Bilanz/Abschlussart'):
artFinal = art.text
abschlussArt.append(artFinal)
konsKreis = []
for kKreis in root.findall('.//Bilanz/Bilanzierungsebene'):
kKreisFinal = kKreis.text
konsKreis.append(kKreisFinal)
ontenrahmen = []
for kRahmen in root.findall('.//Kontenrahmen'):
kRahmenFinal = kRahmen.text
kontenrahmen.append(kRahmenFinal)
identitaet = []
for ident in root.findall('.//IdentMerkmal'):
identFinal = ident.text
identitaet.append(identFinal)
# Perioden und gcd-Informationen der Abschlussdaten
instance_namespaces = dict([node for _, node in ET.iterparse('[...]/instances/MusterholzGmbH/wd/FA/96429000_1002954034_VjNein_KnNein_MlNein.xml',
events=['start-ns'])])
instance_CurrentFY_idRef = []
instance_CurrentFY_period = []
instance_AbschlussInstantEndDatumAktuellesFY = []
instance_AbschlussPeriodeAktuellesFY = []
namespacePeriods = {'xbrli': 'http://www.xbrl.org/2003/instance'}
for idValues in root.findall('.//{http://www.xbrl.org/2003/instance}context', namespacePeriods):
idValuesCount = 0
idValuesCountMax = len(list(idValues))
for idValue in idValues:
idValueTextOnly = idValue.tag.split('}',1)
idValueTextOnlyFinal = idValueTextOnly[1]
if idValueTextOnlyFinal == 'period':
for period in idValue:
periodTextOnly = period.tag.split('}',1)
periodTextOnlyFinal = periodTextOnly[1]
if periodTextOnlyFinal == 'instant':
for stichtagsWert in root.findall('.//{http://www.xbrl.org/2003/instance}instant', namespacePeriods):
stichtagsWertFinal = stichtagsWert.text
instance_AbschlussInstantEndDatumAktuellesFY.append(stichtagsWertFinal)
if instance_AbschlussInstantEndDatumAktuellesFY == abschlussStichtag:
instance_CurrentFY_period.append(stichtagsWert.text)
instance_CurrentFY_idRef.append(idValues.get('id'))
elif periodTextOnlyFinal == 'endDate':
for periodenWert in root.findall('.//{http://www.xbrl.org/2003/instance}endDate', namespacePeriods):
periodenWertFinal = periodenWert.text
instance_AbschlussPeriodeAktuellesFY.append(periodenWertFinal)
if instance_AbschlussPeriodeAktuellesFY == abschlussStichtag:
instance_CurrentFY_period.append(periodenWert.text)
instance_CurrentFY_idRef.append(idValues.get('id'))
idValuesCount =+ 1
dfPeriod = pd.DataFrame({'id': instance_CurrentFY_idRef,'date': instance_CurrentFY_period})
gcdItemTexts = []
gcdItemContents = []
gcdItemContextRefs = []
namespaces = {'de-gcd': 'http://www.xbrl.de/taxonomies/de-gcd-2022-05-02'}
for gcdItem in root.findall('.//{http://www.xbrl.de/taxonomies/de-gcd-2022-05-02}*', namespaces):
gcdItemText = gcdItem.tag.split('}',1)
gcdItemTextOnly = gcdItemText[1]
gcdItemTextFinal = gcdItemTextOnly.removeprefix('genInfo.')
gcdItemTexts.append(gcdItemTextFinal)
gcdItemContent = gcdItem.text
gcdItemContents.append(gcdItemContent)
gcdItemContextRef = gcdItem.get('contextRef')
gcdItemContextRefs.append(gcdItemContextRef)
dfGcd = pd.DataFrame({'label': gcdItemTexts,'labelText': gcdItemContents, 'labelPeriodRef': gcdItemContextRefs})
# Anmerkung: Zuordnung der korrekten Taxonomie (s. Auslesen der xbrl-Taxonomie zuvor)
tax_HGB66 = ['HGB_6.6']
tax_HGB65 = ['HGB_6.5']
tax_HGB64 = ['HGB_6.4']
# ... weitere Taxonomien
# einlesen der zuvor Taxonomie
if set(taxonomie) == set(tax_HGB66):
dfHGB66 = pd.read_csv('[...]/gcd.csv')
# elif / else:
# ... weitere Taxonomien
dfGcdTotalPre = pd.concat([dfHGB66, dfGcd], axis=0, ignore_index=True, sort=True)
dfGcdTotal = dfGcdTotalPre.dropna(subset=['labelPeriodRef'])
filepath = pathlib.Path('[...]/gcd_Example123.csv')
filepath.parent.mkdir(parents=True, exist_ok=True)
dfGcdTotal.to_csv(filepath)
Abschluss-Daten
xbrl-Taxonomie
Auslesen der Informationen aus der xbrl-Taxonomie.
from xml.dom import minidom as md
from xml.dom.minidom import parse
import xml.etree.ElementTree as ET
import pathlib
import pandas as pd
import numpy as np
label = []
labelArc = []
labelArcOP = []
presentationLabel = []
presentationLabelOP = []
presentationLabelOrder = []
calculationLabel = []
calculationLabelOP = []
calculationLabelOrder = []
calculationLabelWeight = []
elementXsd = []
elementBalanceXsd = []
# label-Linkbase
dom = md.parse('[...]/de-gaap-ci-2022-05-02-label-de-group.xml')
elements = dom.getElementsByTagName('label')
elementsArc = dom.getElementsByTagName('labelArc')
for element in elements:
elementValue = element.attributes['xlink:label'].value
elementValueCore = elementValue.split('ci_',2)
elementValueFinal = elementValueCore[1]
label.append(elementValueFinal)
for elementArcFrom in elementsArc:
elementArcLabelValue = elementArcFrom.attributes['xlink:to'].value
elementArcLabelValueCore = elementArcLabelValue.split('ci_',2)
elementArcLabelValueFinal = elementArcLabelValueCore[1]
labelArc.append(elementArcLabelValueFinal)
elementArcFromValue = elementArcFrom.attributes['xlink:from'].value
elementArcFromValueCore = elementArcFromValue.split('ci_',2)
elementArcFromValueFinal = elementArcFromValueCore[1]
labelArcOP.append(elementArcFromValueFinal)
# presentation-Linkbases
file_pres_bs = pathlib.Path('[...]/de-gaap-ci-2022-05-02-presentation-balanceSheet.xml')
file_pres_bsGroup = pathlib.Path('[...]/de-gaap-ci-2022-05-02-presentation-balanceSheet-group.xml')
file_pres_FAGroup = pathlib.Path('[...]/de-gaap-ci-2022-05-02-presentation-notes-fixed-assets-group.xml')
file_pres_notes_FAChange = pathlib.Path('[...]/de-gaap-ci-2022-05-02-table-notesTableStmOfChgInFAssGross.xml')
file_pres_notes_FAChangeCon = pathlib.Path('[...]/de-gaap-ci-2022-05-02-table-notesTableStmOfChgInFAssGrossCond.xml')
file_pres_notes_Rcvbls = pathlib.Path('[...]/de-gaap-ci-2022-05-02-table-notesTableAnalysisOfReceivables.xml')
file_pres_notes_Liablts = pathlib.Path('[...]/de-gaap-ci-2022-05-02-table-notesTableAnalysisOfLiabilities.xml')
file_pres_dim_FaAll = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableStmOfChgInFAssAll.xml')
file_pres_dim_FaGross = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableStmOfChgInFAssGross.xml')
file_pres_dim_FaGrossCon = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableStmOfChgInFAssGrossCond.xml')
file_pres_dim_FaGroupGross = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableStmOfChgInFAssGross-group.xml')
file_pres_dim_FaGroupGrossCon = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableStmOfChgInFAssGrossCond-group.xml')
file_pres_dim_Recvbls_Dim = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableOfReceivables.xml')
file_pres_dim_Recvbls_Dim_Gen = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableOfReceivables-gen.xml')
file_pres_dim_Liablts_Dim = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableOfLiabilities.xml')
file_pres_dim_Liablts_Dim_Gen = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-presentation-notesTableOfLiabilities-gen.xml')
presFileList = [
file_pres_bs,
file_pres_bsGroup,
file_pres_FAGroup,
file_pres_notes_FAChange,
file_pres_notes_FAChangeCon,
file_pres_notes_Rcvbls,
file_pres_notes_Liablts,
file_pres_dim_FaAll,
file_pres_dim_FaGross,
file_pres_dim_FaGrossCon,
file_pres_dim_FaGroupGross,
file_pres_dim_FaGroupGrossCon,
file_pres_dim_Recvbls_Dim,
file_pres_dim_Recvbls_Dim_Gen,
file_pres_dim_Liablts_Dim,
file_pres_dim_Liablts_Dim_Gen
]
for presFile in presFileList:
presDatasource = open(presFile)
presDom = parse(presDatasource)
presentationsArc = presDom.getElementsByTagName('presentationArc')
for presentationArcLabelAndOrder in presentationsArc:
presentationArcLabel = presentationArcLabelAndOrder.attributes['xlink:to'].value
if presentationArcLabel.startswith('de-gaap-ci_'):
presentationArcLabelCore = presentationArcLabel.removeprefix('de-gaap-ci_')
presentationLabel.append(presentationArcLabelCore)
elif presentationArcLabel.startswith('label_de-gaap-ci_'):
presentationArcLabelCore = presentationArcLabel.removeprefix('label_de-gaap-ci_')
presentationLabel.append(presentationArcLabelCore)
elif presentationArcLabel.startswith('extlabel_de-gaap-ci_'):
presentationArcLabelCore = presentationArcLabel.removeprefix('extlabel_de-gaap-ci_')
presentationLabel.append(presentationArcLabelCore)
presentationArcLabelOP = presentationArcLabelAndOrder.attributes['xlink:from'].value
if presentationArcLabelOP.startswith('de-gaap-ci_'):
presentationArcLabelOPCore = presentationArcLabelOP.removeprefix('de-gaap-ci_')
presentationLabelOP.append(presentationArcLabelOPCore)
elif presentationArcLabelOP.startswith('label_de-gaap-ci_'):
presentationArcLabelOPCore = presentationArcLabelOP.removeprefix('label_de-gaap-ci_')
presentationLabelOP.append(presentationArcLabelOPCore)
elif presentationArcLabelOP.startswith('extlabel_de-gaap-ci_'):
presentationArcLabelOPCore = presentationArcLabelOP.removeprefix('extlabel_de-gaap-ci_')
presentationLabelOP.append(presentationArcLabelOPCore)
presentationArcLabelOrderOnly = presentationArcLabelAndOrder.attributes['order'].value
presentationLabelOrder.append(presentationArcLabelOrderOnly)
# calculation-Linkbases
file_calc_bs = pathlib.Path('[...]/de-gaap-ci-2022-05-02-calculation-balanceSheet.xml')
file_calc_bsGroup = pathlib.Path('[...]/de-gaap-ci-2022-05-02-calculation-balanceSheet-group.xml')
file_calc_dim_FAAll = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-calculation-notesTableStmOfChgInFAssAll.xml')
file_calc_dim_FAGross = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-calculation-notesTableStmOfChgInFAssGross.xml')
file_calc_dim_FAGrossCon = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-calculation-notesTableStmOfChgInFAssGrossCond.xml')
file_calc_dim_Recvbls = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-calculation-notesTableOfReceivables.xml')
file_calc_dim_Liablts = pathlib.Path('[...]/de-gaap-ci-2022-05-02-dimensions-calculation-notesTableAnalysisOfLiabilities.xml')
CalcFileList = [
file_calc_bs,
file_calc_bsGroup,
file_calc_dim_FAAll,
file_calc_dim_FAGross,
file_calc_dim_FAGrossCon,
file_calc_dim_Recvbls,
file_calc_dim_Liablts
]
for calcFile in CalcFileList:
calcDatasource = open(calcFile)
calcDom = parse(calcDatasource)
calculationArc = calcDom.getElementsByTagName('calculationArc')
for calculationArcLabelAndOrderAndWeight in calculationArc:
calculationArcLabel = calculationArcLabelAndOrderAndWeight.attributes['xlink:to'].value
if calculationArcLabel.startswith('de-gaap-ci_'):
calculationArcLabelCore = calculationArcLabel.removeprefix('de-gaap-ci_')
calculationLabel.append(calculationArcLabelCore)
elif calculationArcLabel.startswith('label_de-gaap-ci_'):
calculationArcLabelCore = calculationArcLabel.removeprefix('label_de-gaap-ci_')
calculationLabel.append(calculationArcLabelCore)
elif calculationArcLabel.startswith('extlabel_de-gaap-ci_'):
calculationArcLabelCore = calculationArcLabel.removeprefix('extlabel_de-gaap-ci_')
calculationLabel.append(calculationArcLabelCore)
calculationArcLabelOP = calculationArcLabelAndOrderAndWeight.attributes['xlink:from'].value
if calculationArcLabelOP.startswith('de-gaap-ci_'):
calculationArcLabelOPCore = calculationArcLabelOP.removeprefix('de-gaap-ci_')
calculationLabelOP.append(calculationArcLabelOPCore)
elif calculationArcLabelOP.startswith('label_de-gaap-ci_'):
calculationArcLabelOPCore = calculationArcLabelOP.removeprefix('label_de-gaap-ci_')
calculationLabelOP.append(calculationArcLabelOPCore)
elif calculationArcLabelOP.startswith('extlabel_de-gaap-ci_'):
calculationArcLabelOPCore = calculationArcLabelOP.removeprefix('extlabel_de-gaap-ci_')
calculationLabelOP.append(calculationArcLabelOPCore)
calculationArcLabelWeightOnly = calculationArcLabelAndOrderAndWeight.attributes['weight'].value
calculationLabelWeight.append(calculationArcLabelWeightOnly)
# xsd
instance = ET.parse('[...]/de-gaap-ci-2022-05-02.xsd')
root = instance.getroot()
namespacePeriodsXsd = {'xs': 'http://www.w3.org/2001/XMLSchema'}
for elementsInXsd in root.findall('.//{http://www.w3.org/2001/XMLSchema}*', namespacePeriodsXsd):
elementsXsd = elementsInXsd.get('name')
elementXsd.append(elementsXsd)
elementsBalanceXsd = elementsInXsd.get('{http://www.xbrl.org/2003/instance}balance')
elementBalanceXsd.append(elementsBalanceXsd)
# dataframes
dfArc = pd.DataFrame({'label': labelArc,'labelOP': labelArcOP})
dfPresentation = pd.DataFrame({'label': presentationLabel,'labelOP': presentationLabelOP, 'labelOrder': presentationLabelOrder})
dfCalculation = pd.DataFrame({'label': calculationLabel,'labelOP': calculationLabelOP, 'labelWeight': calculationLabelWeight})
dfXsdPrev = pd.DataFrame({'label': elementXsd,'labelBalance': elementBalanceXsd})
dfXsd = dfXsdPrev.dropna(subset=['labelBalance'])
dfTotalPre = pd.merge(dfPresentation, dfArc, left_on='label', right_on='label', how='left')
dfTotalCal = pd.merge(dfCalculation, dfArc, left_on='label', right_on='label', how='left')
dfTotalPreCal = pd.merge(dfTotalPre, dfTotalCal, left_on='label', right_on='label', how='left')
dfTotal = pd.merge(dfTotalPreCal, dfXsd, left_on='label', right_on='label', how='left')
filepath = pathlib.Path('[...]/bs.csv')
filepath.parent.mkdir(parents=True, exist_ok=True)
dfTotal.to_csv(filepath)
Instanzdatei
Auslesen der Informationen aus der Instanzdatei und verknüpfen mit den Taxonomie-Daten.
import os
import pathlib
import xml.etree.ElementTree as ET
import pandas as pd
import numpy as np
# parse
instance = ET.parse('[...]/96429000_1002954034_VjNein_KnJa_MlJa.xml')
root = instance.getroot()
# auslesen / validieren
taxonomie = []
for tax in root.findall('.//Taxonomie'):
taxonomieFinal = tax.text
taxonomie.append(taxonomieFinal)
abschlussStichtag = []
for stichtag in root.findall('.//Bilanz/Abschlussstichtag'):
stichtagFinal = stichtag.text
abschlussStichtag.append(stichtagFinal)
# parsen / auslesen (hier: Periode, Balance Sheet im Beispiel)
instance_namespaces = dict([node for _, node in ET.iterparse('[...]/96429000_1002954034_VjNein_KnNein_MlNein.xml',
events=['start-ns'])])
bsItemTexts = [] # label
bsItemContents = [] # Wert
bsItemContextRefs = [] # Periode
bsItemUnitRefs = [] # Einheit (EUR)
bsItemDecimals = [] # Anzahl der Dezimalstellen (bspw. 2)
bsItemTexts_detInfo = [] # label
bsItemContents_detInfo = [] # Wert
bsItemContextRefs_detInfo = [] # Periode
bsItemUnitRefs_detInfo = [] # Einheit (EUR)
bsItemDecimals_detInfo = [] # Anzahl der Dezimalstellen (bspw. 2)
bsItemAccountNoS_detInfo = [] = [] # Kontenrahmen: Kto-Nummer
bsItemAccountDescrS_detInfo = [] = [] # Kontenrahmen: Kto-Beschreibung
namespaces = {'de-gaap-ci': 'http://www.xbrl.de/taxonomies/de-gaap-ci-2022-05-02'}
for bsItem in root.findall('.//{http://www.xbrl.de/taxonomies/de-gaap-ci-2022-05-02}*', namespaces):
bsItemText = bsItem.tag.split('}',1)
bsItemTextOnly = bsItemText[1]
bsItemTextFinal = bsItemTextOnly.removeprefix('de-gaap-ci:')
if 'detailedInformation.accountBalances' in bsItemTextFinal:
for bsItem_detail in bsItem:
if 'positionName' in bsItem_detail.tag:
bsItemText_detInfo = bsItem_detail.text
bsItemText_detInfoPre = bsItemText_detInfo.split('ci:',1)
bsItemText_detInfoFinal = bsItemText_detInfoPre[1]
bsItemTexts_detInfo.append(bsItemText_detInfoFinal)
if 'amount' in bsItem_detail.tag:
bsItemContent_detInfo = bsItem_detail.text
bsItemContents_detInfo.append(bsItemContent_detInfo)
bsItemContextRef_detInfo = bsItem_detail.get('contextRef')
bsItemContextRefs_detInfo.append(bsItemContextRef_detInfo)
bsItemUnitRef_detInfo = bsItem_detail.get('unitRef')
bsItemUnitRefs_detInfo.append(bsItemUnitRef_detInfo)
bsItemDecimal_detInfo = bsItem_detail.get('decimals')
bsItemDecimals_detInfo.append(bsItemDecimal_detInfo)
if 'accountNumber' in bsItem_detail.tag:
bsItemAccountNo_detInfo = bsItem_detail.text
bsItemAccountNoS_detInfo.append(bsItemAccountNo_detInfo)
if 'accountDescription' in bsItem_detail.tag:
bsItemAccountDescr_detInfo = bsItem_detail.text
bsItemAccountDescrS_detInfo.append(bsItemAccountDescr_detInfo)
elif 'detailedInformation.accountbalances' not in bsItemTextFinal:
bsItemTexts.append(bsItemTextFinal)
bsItemContent = bsItem.text
bsItemContents.append(bsItemContent)
bsItemContextRef = bsItem.get('contextRef')
bsItemContextRefs.append(bsItemContextRef)
bsItemUnitRef = bsItem.get('unitRef')
bsItemUnitRefs.append(bsItemUnitRef)
bsItemDecimal = bsItem.get('decimals')
bsItemDecimals.append(bsItemDecimal)
# dataframes
dfBs = pd.DataFrame({'label': bsItemTexts, 'labelWert': bsItemContents, 'labelWertDezimalstellen': bsItemDecimals, 'labelWertEinheit': bsItemUnitRefs, 'labelPeriode': bsItemContextRefs})
dfBsDetInfo = pd.DataFrame({'label': bsItemTexts_detInfo, 'labelWert': bsItemContents_detInfo, 'labelWertDezimalstellen': bsItemDecimals_detInfo, 'labelWertEinheit': bsItemUnitRefs_detInfo, 'labelPeriode': bsItemContextRefs_detInfo, 'KR_Konto': bsItemAccountNoS_detInfo, 'KR_Beschr': bsItemAccountDescrS_detInfo})
# Anmerkung: Zuordnung der korrekten Taxonomie (s. Auslesen der xbrl-Taxonomie zuvor)
tax_HGB66 = ['HGB_6.6']
tax_HGB65 = ['HGB_6.5']
tax_HGB64 = ['HGB_6.4']
# ... weitere Taxonomien
# einlesen der zuvor Taxonomie
if set(taxonomie) == set(tax_HGB66):
dfHGB66 = pd.read_csv('[...]/bs.csv')
# elif / else:
# ... weitere Taxonomien
dfBsTotalMain = pd.concat([dfBs, dfBsDetInfo], axis=0, ignore_index=True, sort=True)
dfBsTotal = pd.merge(dfBsTotalMain, dfHGB66, left_on='label', right_on='label', how='left')
filepath = pathlib.Path('[...]/bs_Example123.csv')
filepath.parent.mkdir(parents=True, exist_ok=True)
dfGcdTotal.to_csv(filepath)
Beispiel-Datensatz
Übermittlung und Sicherheit
Informationen zu Übermittlung und Sicherheit, sowie weitere Testdaten wird auf Confluence gehosted.
Bitte nutzen Sie das Kontaktformular, damit Sie Zugriff zu dieser Dokumentation erhalten.
Rückkanal
Ebenfalls befinden sich auf Confluence die technischen Spezifikationen zum Rückkanal.
Bitte nutzen Sie das Kontaktformular, damit Sie Zugriff zu dieser Dokumentation erhalten.