Read number of CSV files
Peter Otten
__peter__ at web.de
Mon Nov 12 12:50:25 EST 2012
Peter Otten wrote:
[please don't email me directly]
> How is using glob different from os.listdir() Peter?
glob retains the path and allows you to filter the files. Compare:
>>> import os, glob
>>> os.listdir("alpha")
['one.py', 'two.py', 'one.txt', 'three.py', 'three.txt', 'two.txt']
>>> glob.glob("alpha/*")
['alpha/one.py', 'alpha/two.py', 'alpha/one.txt', 'alpha/three.py',
'alpha/three.txt', 'alpha/two.txt']
>>> glob.glob("alpha/*.py")
['alpha/one.py', 'alpha/two.py', 'alpha/three.py']
See the documentation for more.
More information about the Python-list
mailing list