如何在Python中复制文件?
我找不到任何东西os.
我需要在netcdf文件中处理一个实际包含许多属性和变量的变量.我认为无法更新netcdf文件(请参阅如何删除Scientific.IO.NetCDF.NetCDFFile中的变量的问题?)
我的方法如下:
我的问题是编码第3步.我开始使用以下内容:
def processing(infile, variable, outfile):
data = fileH.variables[variable][:]
# do processing on data...
# and now save the result
fileH = NetCDFFile(infile, mode="r")
outfile = NetCDFFile(outfile, mode='w')
# build a list of variables without the processed variable
listOfVariables = list( itertools.ifilter( lamdba x:x!=variable , fileH.variables.keys() ) )
for ivar in listOfVariables:
# here I need to write each variable and each attribute
Run Code Online (Sandbox Code Playgroud)
如何在不需要重建整个数据结构的情况下将所有数据和属性保存在一小撮代码中?