Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64985
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'pointers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'wrote': 0.14; 'compression': 0.16; 'offsets': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'referencing': 0.16; 'remembered': 0.16; 'slow,': 0.16; 'subsequently': 0.16; 'temp': 0.16; 'types,': 0.16; 'later': 0.20; 'help.': 0.21; 'non': 0.24; 'file.': 0.24; 'header:X-Complaints- To:1': 0.27; 'tried': 0.27; "doesn't": 0.30; 'compared': 0.30; 'direction': 0.30; 'mode': 0.30; 'went': 0.31; 'easier': 0.31; 'lines': 0.31; 'os,': 0.31; 'file': 0.32; 'there.': 0.32; 'text': 0.33; 'but': 0.35; 'building': 0.35; 'version': 0.36; 'module.': 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'handle': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'realize': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'tell': 0.60; 'save': 0.62; "you've": 0.63; 'show': 0.63; 'subject::': 0.85; 'imagine': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re:fseek In Compressed Files |
| Date | Thu, 30 Jan 2014 06:55:32 -0500 (EST) |
| Organization | news.gmane.org |
| References | <68316d1a-e52e-48b5-87df-7119f46ebabc@googlegroups.com> |
| X-Gmane-NNTP-Posting-Host | dpc6744192077.direcpc.com |
| X-Newsreader | PiaoHong Usenet NewsReaders 1.36 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6125.1391082792.18130.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1391082792 news.xs4all.nl 2904 [2001:888:2000:d::a6]:53795 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64985 |
Show key headers only | View raw
Ayushi Dalmia <ayushidalmia2604@gmail.com> Wrote in message: > Hello, > > I need to randomly access a bzip2 or gzip file. How can I set the offset for a line and later retreive the line from the file using the offset. Pointers in this direction will help. > Start with the zlib module. Note that it doesn't handle all possible compression types, like compress and pack. I don't imagine that seeking to a line in a compressed text file would be any easier than a non compressed one. Try using gzip.open in a text mode to get a handle, then loop through it line by line. If you save all the offsets in a list, you should subsequently be able to seek to a remembered offset. But realize it'll be horribly slow, compared to a non compressed one. Consider using readlines and referencing the lines from there. Or building a temp file if too big for ram. If this is not enough, tell us your Python version and your os, and show what you've tried and what went wrong. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-30 02:50 -0800
Re: fseek In Compressed Files Peter Otten <__peter__@web.de> - 2014-01-30 12:28 +0100
Re:fseek In Compressed Files Dave Angel <davea@davea.name> - 2014-01-30 06:55 -0500
Re: fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-30 05:34 -0800
Re: fseek In Compressed Files Chris Angelico <rosuav@gmail.com> - 2014-01-31 00:49 +1100
Re: fseek In Compressed Files Dave Angel <davea@davea.name> - 2014-02-03 15:57 -0500
Re: fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-02-04 04:39 -0800
Re: fseek In Compressed Files Serhiy Storchaka <storchaka@gmail.com> - 2014-01-30 17:02 +0200
Re: fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-30 07:37 -0800
Re: fseek In Compressed Files Dave Angel <davea@davea.name> - 2014-01-30 13:46 -0500
Re: fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-31 21:52 -0800
Re: fseek In Compressed Files Dave Angel <davea@davea.name> - 2014-02-01 04:38 -0500
Re: fseek In Compressed Files Peter Otten <__peter__@web.de> - 2014-01-30 17:21 +0100
Re: fseek In Compressed Files Ayushi Dalmia <ayushidalmia2604@gmail.com> - 2014-01-31 21:50 -0800
Re: fseek In Compressed Files Serhiy Storchaka <storchaka@gmail.com> - 2014-02-03 20:32 +0200
csiph-web