Reading results from glob into a python function -
i trying automate plotting using python , fortran together. close getting work, i'm having problems getting result glob search feed python function.
i have .py script says
import glob run=glob.glob('jun*.aije*.nc') plot_check import plot_check plot_check(run) but getting error
plot_check(run) traceback (most recent call last): file "<stdin>", line 1, in <module> file "plot_check.py", line 7, in plot_check ncfile=dataset(run,'r') file "netcdf4.pyx", line 1328, in netcdf4.dataset.__init__ (netcdf4.c:6336) runtimeerror: no such file or directory i checked glob doing job , is, think it's format of variable "run" that's screwing me up.
in python:
>>run >>['jun3103.aije01ccek0ka.nc'] >>type(run) <type 'list'> so glob finding file name of file want put function, isn't quite working when try input variable "run" in function "plot_check".
i think might format of variable "run", i'm not quite sure how fix it.
any appreciated!
glob.glob returns list of matching filenames. if know there's going 1 file, can grab first element:
filenames = glob.glob('jun*.aije*.nc') plot_check(filenames[0]) or, if might match more 1 file, iterate on results:
filenames = glob.glob('jun*.aije*.nc') filename in filenames: plot_check(filename)
Comments
Post a Comment