Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!w3g2000hsg.googlegroups.com!not-for-mail
From:  Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Need advice on File I/O
Date: Fri, 31 Aug 2007 23:49:39 -0700
Organization: http://groups.google.com
Lines: 32
Message-ID: <1188629379.871780.250890@w3g2000hsg.googlegroups.com>
References: <fbaa6i$3pu$1@fred.mathworks.com>
NNTP-Posting-Host: 85.200.240.26
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1188629380 8957 127.0.0.1 (1 Sep 2007 06:49:40 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 1 Sep 2007 06:49:40 +0000 (UTC)
In-Reply-To: <fbaa6i$3pu$1@fred.mathworks.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: w3g2000hsg.googlegroups.com; posting-host=85.200.240.26;
Xref: news.mathworks.com comp.soft-sys.matlab:426565



On 1 Sep, 02:02, "G.A.M. " <x0z...@gmail.com> wrote:
> I am working with delimited text files (mostly, but not
> always, comma separated or CSV).
>
> Reading and creating entire files isn't a problem. My
> problems start when I need to alter data in existing files.
> I could use some advice.
>
> Sometimes I will need to remove an entire line from a file.
> Sometimes I need to replace a single value (at any row,
> column location) without changing the rest of the file.
>
> After searching and reading everything I can find in the
> help, I am still undecided on how to go about this. I would
> appreciate some advice from experienced Matlab users.
>
> I simply can't see an easy way to modify my file data with
> the Matlab file I/O functions I see listed in help.
>
> (I'm working on Windows and my data is all ASCII. The
> delimiters and data organization in the files is not always
> uniform, so I often have to write code to analyze each
> character I read from a file and figure out where the data
> is that I want to change. However, I don't think there is
> anything really unusual about what I need to do.)

Use regular expressions to parse your files to find the data
you want. Use Walter's method #1, read the data from the source
file and write the altered data set to the destination file.

Rune