Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21544

Re: Fast file data retrieval?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'ascii': 0.07; 'dict': 0.09; 'eof': 0.09; 'from:addr:python': 0.09; 'subject:file': 0.13; 'code?': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 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; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr:python-list': 0.16; 'sqlite3': 0.16; 'stokes': 0.16; 'wrote:': 0.18; 'file,': 0.21; 'header:In-Reply-To:1': 0.22; 'subject:data': 0.25; 'position.': 0.28; 'module.': 0.29; 'retrieval': 0.29; 'lines': 0.30; 'subject:?': 0.31; 'file.': 0.31; 'that,': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'file': 0.34; 'received:84': 0.34; 'rather': 0.34; 'reply-to:addr:python.org': 0.34; 'structured': 0.34; 'probably': 0.35; 'to:addr:python-list': 0.35; '...': 0.35; 'sets': 0.35; 'offset': 0.37; 'could': 0.38; 'several': 0.38; 'data': 0.38; 'header': 0.39; 'put': 0.40; 'to:addr:python.org': 0.40; 'alphanumeric': 0.67; 'header:Reply-To:1': 0.70; 'reply- to:no real name:2**0': 0.72; 'database.': 0.74; 'thousand': 0.74; 'subject:Fast': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=ZZifx7pA c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=qePWxsfFzlIA:10 a=HHWZFyI3HAYA:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=KWwk8Mge0Q1A-kRXCDoA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Mon, 12 Mar 2012 20:31:35 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: Fast file data retrieval?
References <4F5E50F6.9070309@it.uu.se>
In-Reply-To <4F5E50F6.9070309@it.uu.se>
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 <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.592.1331584145.3037.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1331584145 news.xs4all.nl 6877 [2001:888:2000:d::a6]:37489
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21544

Show key headers only | View raw


On 12/03/2012 19:39, Virgil Stokes wrote:
> I have a rather large ASCII file that is structured as follows
>
> header line
> 9 nonblank lines with alphanumeric data
> header line
> 9 nonblank lines with alphanumeric data
> ...
> ...
> ...
> header line
> 9 nonblank lines with alphanumeric data
> EOF
>
> where, a data set contains 10 lines (header + 9 nonblank) and there can
> be several thousand
> data sets in a single file. In addition,*each header has a* *unique ID
> code*.
>
> Is there a fast method for the retrieval of a data set from this large
> file given its ID code?
>
Probably the best solution is to put it into a database. Have a look at
the sqlite3 module.

Alternatively, you could scan the file, recording the ID and the file
offset in a dict so that, given an ID, you can seek directly to that
file position.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Fast file data retrieval? MRAB <python@mrabarnett.plus.com> - 2012-03-12 20:31 +0000
  Re: Fast file data retrieval? Jon Clements <joncle@googlemail.com> - 2012-03-12 20:38 -0700
  Re: Fast file data retrieval? Jon Clements <joncle@googlemail.com> - 2012-03-12 20:38 -0700
  Re: Fast file data retrieval? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-03-13 20:44 +0000
    Re: Fast file data retrieval? Stefan Behnel <stefan_ml@behnel.de> - 2012-03-21 17:32 +0100

csiph-web