Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Read number of CSV files

Reply
Thread Tools

Re: Read number of CSV files

 
 
Peter Otten
Guest
Posts: n/a
 
      11-12-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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Read number of CSV files Peter Otten Python 0 11-08-2012 08:44 AM
csv read clean up and write out to csv Sacha Rook Python 2 11-02-2012 07:51 PM
read CSV file using csv library Li Chen Ruby 18 03-23-2010 12:44 AM
read and write csv file using csv module jliu66 Python 0 10-19-2007 03:12 PM
csv writerow creates double spaced excel csv files Michal Mikolajczyk Python 0 02-13-2004 08:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57