Skip to content

Commit

Permalink
updates to taxonomy loader from Excel
Browse files Browse the repository at this point in the history
  • Loading branch information
Herm Fischer committed Mar 14, 2015
1 parent 7c2bfb9 commit 5e2dc10
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions arelle/plugin/loadFromExcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def loadFromExcel(cntlr, excelFile):

def lbDepthList(lbStruct, depth, parentList=None):
if depth == 0:
return lbStruct[-1].childStruct
if len(lbStruct) > 0:
return lbStruct[-1].childStruct
else:
cntlr.addToLog("Depth error, Excel row: {excelRow}"
.format(excelRow=iRow),
messageCode="importExcel:depth")
return None
return lbDepthList(lbStruct[-1].childStruct, depth-1, list)

extensionElements = {}
Expand Down Expand Up @@ -260,19 +266,22 @@ def checkImport(qname):
for lbEntry in entryList)):
entryList.append( LBentry(prefix=prefix, name=name, arcrole="_dimensions_") )
if hasCalLB:
calcParent = cellValue(row, 'calculationParent')
calcWeight = cellValue(row, 'calculationWeight')
if calcParent and calcWeight:
calcParentPrefix, sep, calcParentName = calcParent.partition(":")
entryList = lbDepthList(calLB, 0)
if entryList is not None:
calRel = (calcParentPrefix, calcParentName, prefix, name)
if calRel not in calRels:
entryList.append( LBentry(prefix=calcParentPrefix, name=calcParentName, isRoot=True, childStruct=
[LBentry(prefix=prefix, name=name, arcrole=XbrlConst.summationItem, weight=calcWeight )]) )
calRels.add(calRel)
else:
pass
calcParents = cellValue(row, 'calculationParent').split()
calcWeights = (str(cellValue(row, 'calculationWeight')) or '').split() # may be float or string
if calcParents and calcWeights:
# may be multiple parents split by whitespace
for i, calcParent in enumerate(calcParents):
calcWeight = calcWeights[i] if i < len(calcWeights) else calcWeights[-1]
calcParentPrefix, sep, calcParentName = calcParent.partition(":")
entryList = lbDepthList(calLB, 0)
if entryList is not None:
calRel = (calcParentPrefix, calcParentName, prefix, name)
if calRel not in calRels:
entryList.append( LBentry(prefix=calcParentPrefix, name=calcParentName, isRoot=True, childStruct=
[LBentry(prefix=prefix, name=name, arcrole=XbrlConst.summationItem, weight=calcWeight )]) )
calRels.add(calRel)
else:
pass

# accumulate extension labels
if useLabels:
Expand Down

0 comments on commit 5e2dc10

Please sign in to comment.