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


Python DataModel.getHeader方法代码示例

本文整理汇总了Python中datamodel.DataModel.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.getHeader方法的具体用法?Python DataModel.getHeader怎么用?Python DataModel.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在datamodel.DataModel的用法示例。


在下文中一共展示了DataModel.getHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ParseDlg

# 需要导入模块: from datamodel import DataModel [as 别名]
# 或者: from datamodel.DataModel import getHeader [as 别名]

#.........这里部分代码省略.........
                line = reg1.sub('', line)
            lines.append(line)
            if preview and len(lines) == 100:
                break
        
        quotechar = None
        if self.quotedFieldCheckBox.isChecked() and self.textLineEdit.text():
            quotechar = str(self.textLineEdit.text())
        
        delim = None
        if self.delimTab.isChecked():
            delim = '\t'
        elif self.delimOther.isChecked() and self.otherLineEdit.text():
            delim = str(self.otherLineEdit.text())
            
        tmpData = None
        if not tmp and self.columnFilterComboBox.currentIndex() > 0 and self.sampleIndicatorComboBox.currentIndex() > 0:
            col = self.columnFilterComboBox.itemData(self.columnFilterComboBox.currentIndex())
            val = self.sampleIndicatorComboBox.itemText(self.sampleIndicatorComboBox.currentIndex())
            if self.headerCheckBox.isChecked():
                tmpData = [line for i,line in enumerate(csv.reader(lines, delimiter=delim, quotechar=quotechar)) if i==0 or line[col] ==  val]
            else:
                tmpData = [line for line in csv.reader(lines, delimiter=delim, quotechar=quotechar) if line[col] ==  val]
        else:
            tmpData = [line for line in csv.reader(lines, delimiter=delim, quotechar=quotechar)]
        if not tmp:
            self.data = tmpData
        return tmpData
            
        
    def updatePreview(self):
        self.parseData(preview=True)
        self.refreshDataTable()
    
    def doParse(self):
        self.done(1)
        
    def updateModel(self):
        if self.headerCheckBox.isChecked():
            self.datatableModel = DataModel(self.data, True)
        else:
            self.datatableModel = DataModel(self.data, False)

    def refreshDataTable(self):
        if not self.data:
            return
        self.updateModel()
        self.datatable.setModel(self.datatableModel)
        self.datatable.horizontalHeader().setVisible(True)
        self.datatable.verticalHeader().setVisible(True)
        self.datatable.setShowGrid(True)
        self.datatable.resizeColumnsToContents()
        self.datatable.resizeRowsToContents()
        headers = copy.copy(self.datatableModel.getHeader())
        headers.insert(0,None)
        if headers != self.header:
            self.updateHeaderCombo(self.statusCombo, headers)
            self.updateHeaderCombo(self.gazexCombo, headers)
            self.updateHeaderCombo(self.gazeyCombo, headers)
            self.updateHeaderCombo(self.timestampCombo, headers)
            self.updateHeaderCombo(self.trialCombo, headers)
            self.updateHeaderCombo(self.columnFilterComboBox, headers)
            self.header = headers
            
    def updateHeaderCombo(self, combobox, headers):
        combobox.clear()
        for i,v in enumerate(headers):
            if i == 0:
                combobox.addItem(v,None)
            else:
                combobox.addItem(v,i-1)
    
    def getSegments(self, status_cb=None):
        segments = []
        tidx = self.trialCombo.currentIndex()-1
        sidx = self.statusCombo.currentIndex()-1
        data = self.datatableModel.getData()
        header = self.datatableModel.getHeader()
        current = [header]
        status = []
        line = 0
        lines = len(data)
        trial = 1
        if tidx != -1:
            trial = data[line][tidx]
        while line < lines:
            if tidx != -1 and data[line][tidx] != trial:
                segments.append({'trial': trial, 'data': current, 'status': status})
                current = [header]
                status = []
                trial = data[line][tidx]
            if sidx == -1:
                status.append(True)
            else:
                status.append(self.comparisonCombo.itemData(self.comparisonCombo.currentIndex())(float(data[line][sidx]),float(self.comparisonValue.text())))
                
            current.append(data[line])
            line += 1
        segments.append({'trial': trial, 'data': current, 'status': status})
        return {self.filename: {'segments': segments, 'firstRowIsHeader': self.headerCheckBox.isChecked()}}
开发者ID:RyanHope,项目名称:PyeTracker,代码行数:104,代码来源:parse.py


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