本文整理汇总了Python中PyFoam.Basics.SpreadsheetData.SpreadsheetData.names方法的典型用法代码示例。如果您正苦于以下问题:Python SpreadsheetData.names方法的具体用法?Python SpreadsheetData.names怎么用?Python SpreadsheetData.names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyFoam.Basics.SpreadsheetData.SpreadsheetData
的用法示例。
在下文中一共展示了SpreadsheetData.names方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest = self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file", dest, "exists already. Use --force to overwrite")
sources = self.parser.getArgs()[0:-1]
data = SpreadsheetData(csvName=sources[0], title=path.splitext(path.basename(sources[0]))[0])
if self.opts.time == None:
self.opts.time = data.names()[0]
for s in sources[1:]:
addition = path.splitext(path.basename(s))[0]
sData = SpreadsheetData(csvName=s)
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:
d = data.resample(
sData,
n,
time=self.opts.time,
extendData=self.opts.extendData,
noInterpolation=not self.opts.newDataInterpolate,
)
data.append(addition + " " + n, d, allowDuplicates=True)
data.writeCSV(dest, delimiter=self.opts.delimiter)
示例2: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest=self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file",dest,"exists already. Use --force to overwrite")
sources=self.parser.getArgs()[0:-1]
data=SpreadsheetData(txtName=sources[0],
timeName=self.opts.time,
validData=self.opts.columns,
title=path.splitext(path.basename(sources[0]))[0])
if self.opts.time==None:
self.opts.time=data.names()[0]
for s in sources[1:]:
addition=path.splitext(path.basename(s))[0]
sData=SpreadsheetData(txtName=s)
for n in sData.names():
if n!=self.opts.time and (self.opts.columns==[] or n in self.opts.columns):
d=data.resample(sData,
n,
time=self.opts.time,
extendData=self.opts.extendData)
data.append(addition+" "+n,d)
data.writeCSV(dest,
delimiter=self.opts.delimiter)
示例3: testSpreadsheetReadFileTest
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testSpreadsheetReadFileTest(self):
fName="/tmp/testdata"
open(fName,"w").write(filecontent)
sp=SpreadsheetData(txtName=fName)
self.assertEqual(len(sp.names()),4)
self.assertEqual(sp.size(),5)
self.assertEqual(sp.tRange(),(0.005,0.025))
self.assertEqual(sp.names()[1],"Initial")
示例4: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest=self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file",dest,"exists already. Use --force to overwrite")
sources=self.parser.getArgs()[0:-1]
data=SpreadsheetData(title=path.splitext(path.basename(sources[0]))[0],
validData=self.opts.columns,
validMatchRegexp=self.opts.columnsRegexp,
**self.dataFormatOptions(sources[0]))
self.printColumns(sources[0],data)
self.recalcColumns(data)
self.rawAddColumns(data)
if self.opts.time==None:
self.opts.time=data.names()[0]
for s in sources[1:]:
addition=path.splitext(path.basename(s))[0]
sData=SpreadsheetData(validData=self.opts.columns,
validMatchRegexp=self.opts.columnsRegexp,
**self.dataFormatOptions(s))
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:
d=data.resample(sData,
n,
time=self.opts.time,
extendData=self.opts.extendData,
noInterpolation=not self.opts.newDataInterpolate)
data.append(addition+" "+n,
d,
allowDuplicates=True)
self.joinedAddColumns(data)
if len(sources)>1:
self.printColumns("written data",data)
if self.opts.writeExcel:
data.getData().to_excel(dest)
else:
data.writeCSV(dest,
delimiter=self.opts.delimiter)
示例5: testGetSpreadsheet
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testGetSpreadsheet(self):
csvName="/tmp/nix.csv"
sd=TimelineDirectory(theDir)
st=sd["p"]
spread=st()
spread.writeCSV(csvName)
self.assertEqual(len(st.positions)+1,len(spread.names()))
rereadSpread=SpreadsheetData(csvName=csvName)
self.assertEqual(len(spread.names()),len(rereadSpread.names()))
self.assertEqual(len(spread.data),len(rereadSpread.data))
sd=TimelineDirectory(theDir,"timeline")
st=sd["p"]
spread=st()
spread.writeCSV("/tmp/nix2.csv")
示例6: testGetSpreadsheet
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testGetSpreadsheet(self):
csvName=path.join(self.theDir,"nix.csv")
sd=TimelineDirectory(self.theDir)
st=sd["p"]
spread=st()
assert len(spread.names())==5
assert spread.size()==3
spread.writeCSV(csvName)
assert len(st.positions)+1==len(spread.names())
rereadSpread=SpreadsheetData(csvName=csvName)
assert len(spread.names())==len(rereadSpread.names())
assert len(spread.data)==len(rereadSpread.data)
sd=TimelineDirectory(self.theDir,"timeline")
st=sd["p"]
spread=st()
spread.writeCSV(path.join(self.theDir,"nix2.csv"))
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder-other-scripting-PyFoam,代码行数:18,代码来源:test_TimelineDirectory.py
示例7: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest=self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file",dest,"exists already. Use --force to overwrite")
sources=[]
for s in self.parser.getArgs()[0:-1]:
if s.find("/*lastTime*/")>=0:
front,back=s.split("/*lastTime*/",1)
for d in glob(front):
lastTime=None
for f in listdir(d):
if path.exists(path.join(d,f,back)):
try:
t=float(f)
if lastTime:
if t>float(lastTime):
lastTime=f
else:
lastTime=f
except ValueError:
pass
if lastTime:
sources.append(path.join(d,lastTime,back))
else:
sources.append(s)
diffs=[None]
if len(sources)>1:
# find differing parts
commonStart=1e4
commonEnd=1e4
for s in sources[1:]:
a=path.abspath(sources[0])
b=path.abspath(s)
start=0
end=0
for i in range(min(len(a),len(b))):
start=i
if a[i]!=b[i]:
break
commonStart=min(commonStart,start)
for i in range(min(len(a),len(b))):
end=i
if a[-(i+1)]!=b[-(i+1)]:
break
commonEnd=min(commonEnd,end)
diffs=[]
for s in sources:
b=path.abspath(s)
if commonEnd>0:
diffs.append(b[commonStart:-(commonEnd)])
else:
diffs.append(b[commonStart:])
names=self.names
title=path.splitext(path.basename(sources[0]))[0]
if self.opts.namesFromFilename:
if not names is None:
self.error("Names already specified as",names,". Can't calc from filename")
names=path.splitext(path.basename(sources[0]))[0].split("_")
title=None
data=SpreadsheetData(names=names,
timeName=self.opts.time,
validData=self.opts.columns,
skip_header=self.opts.skipHeaderLines,
stripCharacters=self.opts.stripCharacters,
replaceFirstLine=self.opts.replaceFirstLine,
validMatchRegexp=self.opts.columnsRegexp,
title=title,
**self.dataFormatOptions(sources[0]))
rawData=[deepcopy(data)]
self.printColumns(sources[0],data)
self.recalcColumns(data)
self.rawAddColumns(data)
if self.opts.time==None:
self.opts.time=data.timeName()
if not diffs[0] is None:
data.rename(lambda c:diffs[0]+" "+c)
for i,s in enumerate(sources[1:]):
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)
#.........这里部分代码省略.........
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder-other-scripting-PyFoam,代码行数:103,代码来源:ConvertToCSV.py
示例8: testSpreadsheetDataExtend
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testSpreadsheetDataExtend(self):
sp1=SpreadsheetData(data=data1,names=names1)
sp1.append("test",[i*i for i in range(len(data1))])
self.assertEqual(len(sp1.names()),len(names1)+1)
self.assert_("test" in sp1.names())
示例9: testSpreadsheetReadFileHandleTest
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testSpreadsheetReadFileHandleTest(self):
sp=SpreadsheetData(txtName=StringIO(filecontent))
self.assertEqual(len(sp.names()),4)
示例10: testSpreadsheetDataConstruction
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def testSpreadsheetDataConstruction(self):
sp=SpreadsheetData(data=data1,names=names1)
self.assertEqual(names1,list(sp.names()))
self.assertEqual(len(sp.data),len(names1)*2)
self.assertEqual(max(sp.data['t']-range(len(names1)*2)),0)
示例11: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest=self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file",dest,"exists already. Use --force to overwrite")
sources=[]
for s in self.parser.getArgs()[0:-1]:
if s.find("/*lastTime*/")>=0:
front,back=s.split("/*lastTime*/",1)
for d in glob(front):
lastTime=None
for f in listdir(d):
if path.exists(path.join(d,f,back)):
try:
t=float(f)
if lastTime:
if t>float(lastTime):
lastTime=f
else:
lastTime=f
except ValueError:
pass
if lastTime:
sources.append(path.join(d,lastTime,back))
else:
sources.append(s)
diffs=[None]
if len(sources)>1:
# find differing parts
commonStart=1e4
commonEnd=1e4
for s in sources[1:]:
a=path.abspath(sources[0])
b=path.abspath(s)
start=0
end=0
for i in range(min(len(a),len(b))):
start=i
if a[i]!=b[i]:
break
commonStart=min(commonStart,start)
for i in range(min(len(a),len(b))):
end=i
if a[-(i+1)]!=b[-(i+1)]:
break
commonEnd=min(commonEnd,end)
diffs=[]
for s in sources:
b=path.abspath(s)
if commonEnd>0:
diffs.append(b[commonStart:-(commonEnd)])
else:
diffs.append(b[commonStart:])
names=None
title=path.splitext(path.basename(sources[0]))[0]
if self.opts.namesFromFilename:
names=path.splitext(path.basename(sources[0]))[0].split("_")
title=None
data=SpreadsheetData(names=names,
timeName=self.opts.time,
validData=self.opts.columns,
validMatchRegexp=self.opts.columnsRegexp,
title=title,
**self.dataFormatOptions(sources[0]))
rawData=[deepcopy(data)]
self.printColumns(sources[0],data)
self.recalcColumns(data)
self.rawAddColumns(data)
if self.opts.time==None:
self.opts.time=data.timeName()
if not diffs[0] is None:
data.rename(lambda c:diffs[0]+" "+c)
for i,s in enumerate(sources[1:]):
names=None
title=path.splitext(path.basename(s))[0]
if self.opts.namesFromFilename:
names=title.split("_")
title=None
sData=SpreadsheetData(names=names,
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)):
#.........这里部分代码省略.........
示例12: run
# 需要导入模块: from PyFoam.Basics.SpreadsheetData import SpreadsheetData [as 别名]
# 或者: from PyFoam.Basics.SpreadsheetData.SpreadsheetData import names [as 别名]
def run(self):
dest=self.parser.getArgs()[-1]
if path.exists(dest) and not self.opts.force:
self.error("CSV-file",dest,"exists already. Use --force to overwrite")
sources=self.parser.getArgs()[0:-1]
diffs=[None]
if len(sources)>1:
# find differing parts
commonStart=1e4
commonEnd=1e4
for s in sources[1:]:
a=path.abspath(sources[0])
b=path.abspath(s)
start=0
end=0
for i in range(min(len(a),len(b))):
start=i
if a[i]!=b[i]:
break
commonStart=min(commonStart,start)
for i in range(min(len(a),len(b))):
end=i
if a[-(i+1)]!=b[-(i+1)]:
break
commonEnd=min(commonEnd,end)
diffs=[]
for s in sources:
b=path.abspath(s)
if commonEnd>0:
diffs.append(b[commonStart:-(commonEnd)])
else:
diffs.append(b[commonStart:])
names=None
title=path.splitext(path.basename(sources[0]))[0]
if self.opts.namesFromFilename:
names=path.splitext(path.basename(sources[0]))[0].split("_")
title=None
data=SpreadsheetData(names=names,
timeName=self.opts.time,
validData=self.opts.columns,
validMatchRegexp=self.opts.columnsRegexp,
title=title,
**self.dataFormatOptions(sources[0]))
self.printColumns(sources[0],data)
self.recalcColumns(data)
self.rawAddColumns(data)
if self.opts.time==None:
self.opts.time=data.names()[0]
for i,s in enumerate(sources[1:]):
names=None
title=path.splitext(path.basename(s))[0]
if self.opts.namesFromFilename:
names=title.split("_")
title=None
sData=SpreadsheetData(names=names,
timeName=self.opts.time,
validData=self.opts.columns,
validMatchRegexp=self.opts.columnsRegexp,
title=title,
**self.dataFormatOptions(s))
self.printColumns(s,sData)
self.recalcColumns(sData)
self.rawAddColumns(sData)
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)
data.append(diffs[i+1]+" "+n,d)
self.joinedAddColumns(data)
if len(sources)>1:
self.printColumns("written data",data)
if self.opts.writeExcel:
data.getData().to_excel(dest)
else:
data.writeCSV(dest,
delimiter=self.opts.delimiter)