Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'bug': 0.02; 'sure.': 0.05; 'python': 0.08; '"r"': 0.09; 'format?': 0.09; 'from:addr:python': 0.09; 'skip:\\ 30': 0.09; 'skip:l 60': 0.09; 'subject:python': 0.10; '"rb"': 0.16; "'r')": 0.16; "'rb')": 0.16; 'compression': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'gzip': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply- to:addr:python-list': 0.16; 'result)': 0.16; 'linux': 0.17; 'subject:Help': 0.17; 'wrote:': 0.18; 'example.': 0.18; 'interesting.': 0.18; 'jan': 0.19; 'appears': 0.19; 'seems': 0.20; 'trying': 0.21; 'subject:list': 0.21; 'result.': 0.21; 'header:In- Reply-To:1': 0.22; 'archive': 0.23; 'fine': 0.24; 'correctly.': 0.24; 'extract': 0.24; 'code': 0.25; 'module': 0.26; 'windows': 0.26; 'import': 0.27; 'tried': 0.27; 'code,': 0.27; 'do.': 0.28; 'random': 0.28; 'fine.': 0.29; 'worked': 0.29; 'pm,': 0.29; 'example': 0.29; 'handling': 0.30; 'kelly': 0.30; 'tar': 0.30; "i've": 0.31; 'thu,': 0.32; 'header:User-Agent:1': 0.33; 'there': 0.33; 'to:addr:python-list': 0.34; 'received:84': 0.34; 'file.': 0.34; 'doc': 0.34; 'reply-to:addr:python.org': 0.34; 'something': 0.35; 'google': 0.35; 'joe': 0.35; 'file': 0.36; 'subject:with': 0.36; 'but': 0.37; 'think': 0.37; 'could': 0.37; 'open': 0.38; 'using': 0.38; 'same.': 0.39; 'else': 0.39; 'files': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'download': 0.60; 'your': 0.61; 'levels': 0.64; '2012': 0.67; 'header:Reply-To:1': 0.71; 'reply- to:no real name:2**0': 0.72; 'something.': 0.84; 'locally': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=A/buztqG c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=9jsOeB20M3cA:10 a=2HxXiLbU_NsA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=pGLkceISAAAA:8 a=tqCXuL6-vmC-nB8U4LYA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Fri, 06 Jan 2012 01:27:00 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Help with python-list archives 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325813187 news.xs4all.nl 6934 [2001:888:2000:d::a6]:53051 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18573 On 06/01/2012 00:10, Ian Kelly wrote: > On Thu, Jan 5, 2012 at 4:52 PM, random joe wrote: >> Sure. Take the most recent file as example. "2012 - January.txt.gz". >> If you use the python doc example this is the result. If i use "r" or >> "rb" the result is the same. >> >>>>> import gzip >>>>> f1 = gzip.open('C:\\2012-January.txt.gz', 'rb') >>>>> data = f1.read() >>>>> data[:100] >> '\x1f\x8b\x08\x08x\n\x05O\x02\xff/srv/mailman/archives/private/python- >> list/2012-January.txt\x00\xec\xbdy\x7f\xdb\xc6\xb50\xfcw\xf0)\xa6z|+ >> \xaa!!l\xdc\x14[\x8b-;V\xe2-\x92\x12' >>>>> f2 = gzip.open('C:\\2012-January.txt.gz', 'r') >>>>> data = f2.read() >>>>> data[:100] >> '\x1f\x8b\x08\x08x\n\x05O\x02\xff/srv/mailman/archives/private/python- >> list/2012-January.txt\x00\xec\xbdy\x7f\xdb\xc6\xb50\xfcw\xf0)\xa6z|+ >> \xaa!!l\xdc\x14[\x8b-;V\xe2-\x92\x12' >> >> The docs and google provide no clear answer. I even tried 7zip and >> ended up with nothing but gibberish characters. There must be levels >> of compression or something. Why could they not simply use the tar >> format? Is there anywhere else one can download the archives? > > Interesting. I tried this on a Linux system using both gunzip and > your code, and both worked fine to extract that file. I also tried > your code on a Windows system, and I get the same result that you do. > This appears to be a bug in the gzip module under Windows. > > I think there may be something peculiar about the archive files that > the module is not handling correctly. If I gunzip the file locally > and then gzip it again before trying to open it in Python, then > everything seems to be fine. I've found that if I gunzip it twice (gunzip it and then gunzip the result) using the gzip module I get the text file.