io - Python loop over files in directory as function argument -
in python scirpt have function func01 takes pdf file argument:
func01("pdf1.pdf") this works , gives me expected output.
now want perform func01 on files in directory. tried this:
import glob, os os.chdir("/articles") file in glob.glob("*.pdf"): myoutput = func01(file) ... not work: typeerror: 'str' object not callable
searching on so, re-wrote script to:
for file in glob.glob("*.pdf"): path_ = os.path.realpath(file) myputput = func01(path_) so want use each file loop input function. missing in code?
your error message
typeerror: 'str' object not callable
implies somewhere along line you're doing "some string"(...). in code posted have few function calls.
os.chdir("/articles")glob.glob("*.pdf")myoutput = func01(file)
so either os.chdir, glob.glob, or func01 have been overwritten string.
Comments
Post a Comment