Re: working with csv module in python

Discussion in 'Python' started by Peter Otten, Feb 20, 2013.

  1. Peter Otten

    Peter Otten Guest

    inshu chauhan wrote:

    > Yes I just want to concat the files , not parse/mangle the files. How
    > can
    > i simply read all files in a folder in my computer and write them into a
    > single file ? just by 'printf ' is it possible ?


    Assuming the files' last line always ends with a newline and the files use
    the same newline convention:

    OUTFILE = "/path/to/outfile.barf"
    infiles = glob.glob("/some/folder/*.arff")

    with open(OUTFILE, "wb") as outstream:
    for infile in infiles:
    with open(infile, "rb") as instream:
    shutil.copyfileobj(instream, outstream)
     
    Peter Otten, Feb 20, 2013
    #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. Daniel Ortmann
    Replies:
    4
    Views:
    584
    Skip Montanaro
    Jul 2, 2003
  2. jliu66
    Replies:
    0
    Views:
    516
    jliu66
    Oct 19, 2007
  3. Roland Koebler

    Re: working with csv module in python

    Roland Koebler, Feb 20, 2013, in forum: Python
    Replies:
    0
    Views:
    128
    Roland Koebler
    Feb 20, 2013
  4. Dave Angel

    Re: working with csv module in python

    Dave Angel, Feb 20, 2013, in forum: Python
    Replies:
    0
    Views:
    138
    Dave Angel
    Feb 20, 2013
  5. Dave Angel

    Re: working with csv module in python

    Dave Angel, Feb 20, 2013, in forum: Python
    Replies:
    0
    Views:
    147
    Dave Angel
    Feb 20, 2013
Loading...

Share This Page