Unzipping Files

Discussion in 'Python' started by Greg Lindstrom, Apr 1, 2005.

  1. Hello-
    I am trying to read a file from a zip archive. I have read the
    documentation on zipfile and can read the names of the files in the
    archive and the length of each file, but do not see how to get to the
    actual data from any given file. This is probably so simple that it
    hurts, so take it easy on me if you please...I just don't see it and
    have a deadline rushing towards me. How do I read the data from a file
    in a zip archive?

    Thanks!
    --greg

    --
    Greg Lindstrom 501 975.4859 (office)
    Senior Programmer 501 219-4455 (fax)
    NovaSys Health
    Little Rock, Arkansas

    "We are the music makers, and we are the dreamers of dreams." W.W.
     
    Greg Lindstrom, Apr 1, 2005
    #1
    1. Advertising

  2. Greg Lindstrom

    Larry Bates Guest

    Use something like:

    import zipfile
    zfile=zipfile.ZipFile(zipfilename,'r')
    contents=zfile.read(filenametoread)

    Stripped out of a working program, but not tested.

    -Larry Bates


    Greg Lindstrom wrote:
    > Hello-
    > I am trying to read a file from a zip archive. I have read the
    > documentation on zipfile and can read the names of the files in the
    > archive and the length of each file, but do not see how to get to the
    > actual data from any given file. This is probably so simple that it
    > hurts, so take it easy on me if you please...I just don't see it and
    > have a deadline rushing towards me. How do I read the data from a file
    > in a zip archive?
    >
    > Thanks!
    > --greg
    >
     
    Larry Bates, Apr 1, 2005
    #2
    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. Timothy Martens
    Replies:
    2
    Views:
    310
    Steve J. Martin
    Aug 2, 2003
  2. John Machin
    Replies:
    3
    Views:
    346
    John Latter
    Aug 2, 2003
  3. Doug Tolton

    Zipping and Unzipping files

    Doug Tolton, Nov 21, 2003, in forum: Python
    Replies:
    1
    Views:
    331
    Peter Hansen
    Nov 21, 2003
  4. Doug Tolton

    File unzipping

    Doug Tolton, Dec 9, 2003, in forum: Python
    Replies:
    0
    Views:
    309
    Doug Tolton
    Dec 9, 2003
  5. webcomm
    Replies:
    10
    Views:
    758
    John Machin
    Jan 10, 2009
Loading...

Share This Page