本文整理汇总了Python中Table.Table.getColumnList方法的典型用法代码示例。如果您正苦于以下问题:Python Table.getColumnList方法的具体用法?Python Table.getColumnList怎么用?Python Table.getColumnList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table.Table
的用法示例。
在下文中一共展示了Table.getColumnList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: decomposeTables
# 需要导入模块: from Table import Table [as 别名]
# 或者: from Table.Table import getColumnList [as 别名]
def decomposeTables(self):
for multiLineBlock in self.__multiLineBlocksList:
linesBefore = 0
lineCount = 0
if (multiLineBlock.getEnd() - multiLineBlock.getBegin()) >= 2:
# multiline blocks with less than 3 lines will be ignored
myRootNode = MyNode(level = -1, content = "root")
for begin in range(int(multiLineBlock.getBegin()), int(multiLineBlock.getEnd())+1):
line = self.__linesList[begin]
for textElement in line.getTextList():
self.insertIntoTree(textElement, myRootNode, linesBefore)
linesBefore += 1
# end of while (begin <= multiLineBlock.getEnd())
#self.printTree(myRootNode)
newTable = Table()
self.convertToTable(myRootNode, None, newTable.getColumnList(), linesBefore)
for pos in range(0, len(newTable.getColumnList())-1):
firstColumn = newTable.getColumnListElement(pos)
secondColumn = newTable.getColumnListElement(pos+1)
nextColumn = firstColumn.clone()
if firstColumn.getLeft() <= secondColumn.getLeft() and \
firstColumn.getRight() >= secondColumn.getLeft():
# merge columns because they overlap
merge = True
for posCounter in range(0, len(firstColumn.getCellsList())):
firstTextElement = firstColumn.getCellsListElement(posCounter)
secondTextElement = secondColumn.getCellsListElement(posCounter)
nextTextElement = nextColumn.getCellsListElement(posCounter)
if firstTextElement.getValue() == "null" or secondTextElement.getValue() == "null":
newValue = ""
if firstTextElement.getValue() != "null":
nextTextElement.setValue(firstTextElement.getValue())
if firstTextElement.getColspan() > 1:
nextTextElement.setColspan(nextTextElement.getColspan() -1)
else:
self.updateColumnValues(nextColumn, firstTextElement)
else:
nextTextElement.setValue(secondTextElement.getValue())
if (secondTextElement.getColspan() > 1):
nextTextElement.setColspan(nextTextElement.getColspan() -1)
else:
self.updateColumnValues(nextColumn,secondTextElement)
else:
merge = False
break
if merge == True:
newTable.insertColumnAt(pos, nextColumn)
newTable.removeColumnAt(pos+1)
newTable.removeColumnAt(pos+1)
newTable.setDatarowBegin(0) #data_row_begin
header = True
sumTotal = 0
if len(newTable.getColumnList()) > 0:
firstColumn = newTable.getColumnListElement(0)
for pos in range(0, len(firstColumn.getCellsList())):
if header == True:
for counter in range(0, len(newTable.getColumnList())):
currentColumn = newTable.getColumnListElement(counter)
textElement = currentColumn.getCellsListElement(pos)
if textElement.isArtificial() == False:
sumTotal = sumTotal + textElement.getColspan()
if sumTotal >= multiLineBlock.getMaxElements():
header = False
newTable.setDatarowBegin(pos+1)
newTable.setPage(multiLineBlock.getPage())
self.__tableList.append(newTable)