From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Johan Andersson Newsgroups: gmane.emacs.help Subject: Re: Datastructure for table Date: Fri, 15 Jan 2010 16:45:32 +0000 Message-ID: <929ccd881001150845v3b2196eduea5c5d6928ad2696@mail.gmail.com> References: <87fx68cj2r.fsf@lion.rapttech.com.au> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6d7ef1664d3e5047d36bb33 X-Trace: ger.gmane.org 1263574080 7595 80.91.229.12 (15 Jan 2010 16:48:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Jan 2010 16:48:00 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Tim X Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 15 17:47:53 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NVpKu-0000RP-DY for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Jan 2010 17:47:48 +0100 Original-Received: from localhost ([127.0.0.1]:49464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVpKv-00080H-5X for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Jan 2010 11:47:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVpIp-0006Zq-JU for help-gnu-emacs@gnu.org; Fri, 15 Jan 2010 11:45:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVpIk-0006QE-Pt for help-gnu-emacs@gnu.org; Fri, 15 Jan 2010 11:45:38 -0500 Original-Received: from [199.232.76.173] (port=45009 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVpIk-0006Q1-Bt for help-gnu-emacs@gnu.org; Fri, 15 Jan 2010 11:45:34 -0500 Original-Received: from gv-out-0910.google.com ([216.239.58.191]:62511) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NVpIj-0008Pz-Ng for help-gnu-emacs@gnu.org; Fri, 15 Jan 2010 11:45:34 -0500 Original-Received: by gv-out-0910.google.com with SMTP id c6so84776gvd.17 for ; Fri, 15 Jan 2010 08:45:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=EAhOR92eXRx4YDFgtE1irzKdd7D1Ut+pKcUJQVXin50=; b=B7Mmtp7+QQDicQuDz5N154LOBuWtkzbpn7+Q6QYlxQRSsIYrfBN1Fu8Gk4QIFO+Xf/ bN+X422amXybPulULL6b3d0JaclIydulc1Jiz3+CxKDFn2We+eHDdYFMuWVjpYvWB356 FQsDCIgsJM5ZFVie/6OCzup3nBBLh7gLvLQmY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Hrey6w4M4CbBMhGQmJDgYtMZ0hyrbJAVH/ktsVVirSXBHYkr8eYZHyX0Ox4WARQsBN BTqW4gCOS/RAPiqi4N1ZTzhUmp+p0f4DwDEWjc1cKcI99ztwAsvC17dSJ47k1VgQ5lpt 92z4melX27ehwYjBBE5Mm0uaW9sjtXsZ1/i4o= Original-Received: by 10.216.93.81 with SMTP id k59mr952581wef.169.1263573932495; Fri, 15 Jan 2010 08:45:32 -0800 (PST) In-Reply-To: <87fx68cj2r.fsf@lion.rapttech.com.au> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71239 Archived-At: --0016e6d7ef1664d3e5047d36bb33 Content-Type: text/plain; charset=ISO-8859-1 I will try to think from the "use perspective" as you say and figure out which of them that works best. Thanks! On Fri, Jan 15, 2010 at 12:23 AM, Tim X wrote: > Johan Andersson writes: > > > Hey, > > > > I have an Org-table looking like this: > > | person | car | wife | > > | John | Volvo | Susan | > > | Peter | BMW | Greta | > > | Stefan | Golf | Althea | > > > > I want to parse this so that I get one object per row (execpt the > > header, which defines the keys). So if I for example have the first > > object, I want to be able to fetch the value of some column given the > > header key. The table is dynamic and can have any number of columns > > and the header names differ. > > > > What kind of datastructure would fit for this? I can think of a few > > that may work (Hash-table, Struct and Plist), but none that fit very > > well. > > > > Well, its difficult to say what structure would work best because this > really depends on what you plan to do with the data and the relative > frequencies of the various operations you will be performing. > > Additional options you didn't mention could include > > 1 Association lists. Keys would be columns. Has the advantage > of being able to use assoc etc to get/set values > 2 Nested lists. First sublist could be the list of column > names. Subsequent lists could be each record. > 4. Objects i.e. EIEIO (Enhanced Implementation of Emacs > Interpreted Objects) > > Assuming the tables will vary re: columns and column names and assuming > as these are org based tables, there not going to be that large, I would > be tempted to go with alist or nested lists. However, it really depends > on what you plan to do with the data. If your not going to be updating > the values much, nested lists could be pretty easy to implement. > However, if you need access to specific column values, alist may be > better. > > Choose the structure that makes the most frequent or most complex > operations easiest to code and maintain. > > Tim > > > > -- > tcross (at) rapttech dot com dot au > --0016e6d7ef1664d3e5047d36bb33 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I will try to think from the "use perspective" as you say and fig= ure out which of them that works best.

Thanks!

On Fri, Jan 15, 2010 at 12:23 AM, Tim X <= timx@nospam.dev.null> wrote:
<= div class=3D"h5">Johan Andersson <johan.rejeep@gmail.com> writes:

> Hey,
>
> I have an Org-table looking like this:
> | person | car =A0 =A0 | wife =A0 =A0=A0 |
> | John=A0=A0=A0=A0 | Volvo | Susan |
> | Peter=A0=A0=A0 | BMW=A0 | Greta=A0=A0 |
> | Stefan=A0 | Golf=A0=A0=A0 | Althea=A0 |
>
> I want to parse this so that I get one object per row (execpt the
> header, which defines the keys). So if I for example have the first > object, I want to be able to fetch the value of some column given the<= br> > header key. The table is dynamic and can have any number of columns > and the header names differ.
>
> What kind of datastructure would fit for this? I can think of a few > that may work (Hash-table, Struct and Plist), but none that fit very > well.
>

Well, its difficult to say what structure would work best becau= se this
really depends on what you plan to do with the data and the relative
frequencies of the various operations you will be performing.

Additional options you didn't mention could include

=A0 =A0 =A0 =A0 =A0 1 Association lists. Keys would be columns. Has the ad= vantage
=A0 =A0 =A0 =A0 =A0 of being able to use assoc etc to get/set values
=A0 =A0 =A0 =A0 =A0 2 Nested lists. First sublist could be the list of col= umn
=A0 =A0 =A0 =A0 =A0 names. Subsequent lists could be each record.
=A0 =A0 =A0 =A0 =A0 4. Objects i.e. EIEIO (Enhanced Implementation of Emac= s
=A0 =A0 =A0 =A0 =A0 Interpreted Objects)

Assuming the tables will vary re: columns and column names and assuming
as these are org based tables, there not going to be that large, I would be tempted to go with alist or nested lists. However, it really depends
on what you plan to do with the data. If your not going to be updating
the values much, nested lists could be pretty easy to implement.
However, if you need access to specific column values, alist may be
better.

Choose the structure that makes the most frequent or most complex
operations easiest to code and maintain.

Tim



--
tcross (at) rapttech dot com dot au

--0016e6d7ef1664d3e5047d36bb33--