Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Read number of CSV files (http://www.velocityreviews.com/forums/t954440-re-read-number-of-csv-files.html)

Peter Otten 11-12-2012 05:50 PM

Re: Read number of CSV files
 
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.



All times are GMT. The time now is 10:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.