Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18587
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.42!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'mrab': 0.04; 'subject:python': 0.10; 'intermediate': 0.15; 'gzip': 0.16; 'stringio': 0.16; 'received:74.125.82.44': 0.16; 'received:mail- ww0-f44.google.com': 0.16; 'subject:Help': 0.17; 'wrote:': 0.18; 'instance': 0.18; 'jan': 0.19; 'memory': 0.21; 'subject:list': 0.21; 'header:In-Reply-To:1': 0.22; 'creating': 0.25; 'import': 0.27; 'message-id:@mail.gmail.com': 0.28; 'pm,': 0.29; 'necessary.': 0.32; 'thu,': 0.32; 'sort': 0.33; "won't": 0.33; 'to:addr:python-list': 0.34; 'received:74.125.82': 0.35; 'file': 0.36; 'subject:with': 0.36; 'received:74.125': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'could': 0.37; 'using': 0.38; 'some': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.40; 'skip:o 30': 0.63; '2012': 0.67 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=EZWbyS6YCVAaLBFSBB9FNU9Tpj+UjLKTIKQO5if+spY=; b=EndvtR9T0R2dmESFGvHsw2W3VE7JsRCHYMJ8tbAWHNSSmAAn7N6abVQfM9Hoa2uhhu 5LGF1XwEhA1JuFckA+SuLFbwNe/+OiZyhTER3YD1HaMbMSswuaaZrwv+zjI30BT3yWeF dR1cMHMnjHpubuOzZALwSq+yEjaWNk7gg0E50= |
| MIME-Version | 1.0 |
| In-Reply-To | <4F0663E8.4090302@mrabarnett.plus.com> |
| References | <78484055-dd01-4237-9217-9eb038fc744f@p16g2000yqd.googlegroups.com> <14749754.624.1325806776674.JavaMail.geo-discussion-forums@vbgw2> <8f3b98e1-3b21-4f06-8456-0a555a7ee523@u32g2000yqe.googlegroups.com> <CALwzidn5zJVYPsViSx-SV25Ef5qSsY0d8bX=6rcdvPBu8UydZw@mail.gmail.com> <mailman.4464.1325813187.27778.python-list@python.org> <fa7b56e3-68b1-4b37-834d-48ab73177baf@k28g2000yqn.googlegroups.com> <4F0663E8.4090302@mrabarnett.plus.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 6 Jan 2012 00:41:01 -0700 |
| Subject | Re: Help with python-list archives |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4472.1325835693.27778.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1325835693 news.xs4all.nl 6922 [2001:888:2000:d::a6]:38558 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18587 |
Show key headers only | View raw
On Thu, Jan 5, 2012 at 8:00 PM, MRAB <python@mrabarnett.plus.com> wrote:
> import gzip
>
> in_file = gzip.open(r"C:\2012-January.txt.gz")
> out_file = open(r"C:\2012-January.txt.tmp", "wb")
> out_file.write(in_file.read())
> in_file.close()
> out_file.close()
>
> in_file = gzip.open(r"C:\2012-January.txt.tmp")
> out_file = open(r"C:\2012-January.txt", "wb")
> out_file.write(in_file.read())
> in_file.close()
> out_file.close()
One could also avoid creating the intermediate file by using a
StringIO to keep it in memory instead:
import gzip
from cStringIO import StringIO
in_file = gzip.open('2012-January.txt.gz')
tmp_file = StringIO(in_file.read())
in_file.close()
in_file = gzip.GzipFile(fileobj=tmp_file)
out_file = open('2012-January.txt', 'wb')
out_file.write(in_file.read())
in_file.close()
out_file.close()
Sadly, GzipFile won't read directly from another GzipFile instance
(ValueError: Seek from end not supported), so some sort of
intermediate is necessary.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 14:44 -0800
Re: Help with python-list archives Miki Tebeka <miki.tebeka@gmail.com> - 2012-01-05 15:39 -0800
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 15:52 -0800
Re: Help with python-list archives Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-05 17:10 -0700
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 16:45 -0800
Re: Help with python-list archives MRAB <python@mrabarnett.plus.com> - 2012-01-06 01:27 +0000
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 18:14 -0800
Re: Help with python-list archives MRAB <python@mrabarnett.plus.com> - 2012-01-06 03:00 +0000
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 20:01 -0800
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-05 20:08 -0800
Re: Help with python-list archives Chris Angelico <rosuav@gmail.com> - 2012-01-06 15:12 +1100
Re: Help with python-list archives Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 00:45 -0700
Re: Help with python-list archives Anssi Saari <as@sci.fi> - 2012-01-10 16:47 +0200
Re: Help with python-list archives Chris Angelico <rosuav@gmail.com> - 2012-01-06 15:11 +1100
Re: Help with python-list archives Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-06 00:41 -0700
Re: Help with python-list archives random joe <pywin32@gmail.com> - 2012-01-06 16:55 -0800
Re: Help with python-list archives Ian Kelly <ian.g.kelly@gmail.com> - 2012-01-05 17:02 -0700
csiph-web