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


Python SpreadsheetData.eliminatedNames方法代码示例

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


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

示例1: run

# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import eliminatedNames [as 别名]

#.........这里部分代码省略.........
            names=None
            title=path.splitext(path.basename(s))[0]
            if self.opts.namesFromFilename:
                names=title.split("_")
                title=None
            sData=SpreadsheetData(names=names,
                                  skip_header=self.opts.skipHeaderLines,
                                  stripCharacters=self.opts.stripCharacters,
                                  replaceFirstLine=self.opts.replaceFirstLine,
                                  timeName=self.opts.time,
                                  validData=self.opts.columns,
                                  validMatchRegexp=self.opts.columnsRegexp,
                                  title=title,
                                  **self.dataFormatOptions(s))
            rawData.append(sData)
            self.printColumns(s,sData)
            self.recalcColumns(sData)
            self.rawAddColumns(sData)

            if self.opts.addTimes:
                data.addTimes(time=self.opts.time,
                               times=sData.data[self.opts.time],
                               interpolate=self.opts.interpolateNewTime)
            for n in sData.names():
                if n!=self.opts.time and (self.opts.columns==[] or data.validName(n,self.opts.columns,True)):
                    d=data.resample(sData,
                                    n,
                                    time=self.opts.time,
                                    extendData=self.opts.extendData,
                                    noInterpolation=not self.opts.newDataInterpolate)
                    data.append(diffs[i+1]+" "+n,d)

        self.joinedAddColumns(data)
        data.rename(self.processName,renameTime=True)
        data.rename(lambda c:c.strip())

        data.eliminatedNames=None
        if len(sources)>1:
            self.printColumns("written data",data)

        if self.opts.automaticFormat:
            if self.getDataFormat(dest)=="excel":
                self.opts.writeExcel=True

        if self.opts.writeExcel:
            from pandas import ExcelWriter
            with ExcelWriter(dest) as writer:
                data.getData().to_excel(writer,sheet_name="Data")
                if self.opts.addSheets:
                    for n,d in enumerate(rawData):
                        d.getData().to_excel(writer,
                                             sheet_name="Original file %d" % n)
                if hasXlsxWriter:
                    if len(self.opts.addFormulas)>0:
                        from xlsxwriter.utility import xl_rowcol_to_cell as rowCol2Cell
                        rows=len(data.getData())
                        sheet=writer.sheets["Data"]
                        cols={}
                        for i,n in enumerate(data.names()):
                            cols[n]=i
                            newC=i

                        for f in self.opts.addFormulas:
                            newC+=1
                            name,formula=f.split(":::")
                            sheet.write(0,newC,name)
                            cols[name]=newC
                            splitted=[]
                            ind=0
                            while ind>=0:
                                if ind>=len(formula):
                                    break
                                nInd=formula.find("'",ind)
                                if nInd<0:
                                    splitted.append(formula[ind:])
                                    ind=nInd
                                elif nInd!=ind:
                                    splitted.append(formula[ind:nInd])
                                    ind=nInd
                                else:
                                    nInd=formula.find("'",ind+1)
                                    if nInd<0:
                                        self.error("No closing ' in formula",formula)
                                    name=formula[ind+1:nInd]
                                    if name not in cols:
                                        self.error("Name",name,"not in column names",cols.keys())
                                    splitted.append(cols[name])
                                    ind=nInd+1
                            for row in range(rows):
                                cellFormula="="
                                for s in splitted:
                                    if type(s)==int:
                                        cellFormula+=rowCol2Cell(row+1,s)
                                    else:
                                        cellFormula+=s
                                sheet.write(row+1,newC,cellFormula)
                        print_("Formulas written. In LibreOffice recalculate with Ctrl+Shift+F9")
        else:
            data.writeCSV(dest,
                          delimiter=self.opts.delimiter)
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder-other-scripting-PyFoam,代码行数:104,代码来源:ConvertToCSV.py


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