当前位置: 首页>>代码示例>>Python>>正文


Python Table.getColumnList方法代码示例

本文整理汇总了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)
开发者ID:B-Rich,项目名称:pypdf2table,代码行数:82,代码来源:SecondClassification.py


注:本文中的Table.Table.getColumnList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。