Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
Newsgroups: comp.soft-sys.matlab
Subject: Re: Need advice on File I/O
References: <fbaa6i$3pu$1@fred.mathworks.com> <fbcpdd$b7$1@fred.mathworks.com> <fbd23f$jt2$1@fred.mathworks.com>
From: Peter Boettcher <boettcher@ll.mit.edu>
Message-ID: <muy7in6qxky.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:3508LHdzURt7SpyKOufp4CQCpNg=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 34
Date: Tue, 04 Sep 2007 11:06:37 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1188918088 155.34.163.114 (Tue, 04 Sep 2007 11:01:28 EDT)
NNTP-Posting-Date: Tue, 04 Sep 2007 11:01:28 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:426902



"G.A.M. " <x0zero@gmail.com> writes:

> "Bill " <william.nospam.a.cobb@gm.com> wrote in message
> <fbcpdd$b7$1@fred.mathworks.com>...
>
> It seems like my options are coming down to either Excel or
> a database. But I was hoping for a solution that involved
> CSV/ASCII files. My past experience tells me that using a
> database will probably be slower than writing to CSV files.

Unless you are talking about bulk saving or loading, I very much doubt
that!

> (I don't know how using one of the options to write to
> Excel-formatted files will compare in speed.) I also like
> the fact that ASCII text files, besides being generally fast
> than a db, are really easy to deal with.

Well, you are discovering precisely the things that make an ASCII file
difficult to deal with.  They are very bad at random access, and
nearly impossible to do single-entry modifications.  Higher-level
wrappers like csvwrite, etc, will not change this.  It may hide some
of the nastiness, but it will still probably rewrite the entire file.
When I say bad, I mean slow and complex to implement.

Databases are very good at randomly accessing elements, and at
modifying, inserting, etc.

A third option not mentioned here is a binary file.  If your data
items are numeric, then random access is easy (via fseek, or even via
memmapfile), and any item may be easily changed.  You can also easily
append.  You still cannot delete or insert items, or shorten the file.

-Peter