Re: Read number of CSV files

Discussion in 'Python' started by Peter Otten, Nov 12, 2012.

  1. Peter Otten

    Peter Otten Guest

    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.
     
    Peter Otten, Nov 12, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michal Mikolajczyk
    Replies:
    0
    Views:
    690
    Michal Mikolajczyk
    Feb 13, 2004
  2. jliu66
    Replies:
    0
    Views:
    559
    jliu66
    Oct 19, 2007
  3. Li Chen
    Replies:
    18
    Views:
    715
    Azmi Farih
    Mar 23, 2010
  4. Sacha Rook

    csv read clean up and write out to csv

    Sacha Rook, Nov 2, 2012, in forum: Python
    Replies:
    2
    Views:
    244
    Hans Mulder
    Nov 2, 2012
  5. Peter Otten

    Re: Read number of CSV files

    Peter Otten, Nov 8, 2012, in forum: Python
    Replies:
    0
    Views:
    230
    Peter Otten
    Nov 8, 2012
Loading...

Share This Page