Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!e8g2000yqo.googlegroups.com!not-for-mail
From: Rune Allnor <allnor@tele.ntnu.no>
Newsgroups: comp.soft-sys.matlab
Subject: Re: alternative to laod file?
Date: Tue, 29 Sep 2009 03:46:16 -0700 (PDT)
Organization: http://groups.google.com
Lines: 25
Message-ID: <d9f2404e-9774-4ee2-bda3-472235cc1296@e8g2000yqo.googlegroups.com>
References: <h9snuj$csk$1@fred.mathworks.com>
NNTP-Posting-Host: 77.17.160.70
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1254221176 26086 127.0.0.1 (29 Sep 2009 10:46:16 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 29 Sep 2009 10:46:16 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: e8g2000yqo.googlegroups.com; posting-host=77.17.160.70; 
	posting-account=VAp5gAkAAAAmkCze5hvZtMeedpZWNthI
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; 
	Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; 
	.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:573622


On 29 Sep, 12:36, "M K" <mah...@mathworks.com> wrote:
> Hi !
>
> I have a series of large ASCII files which I want to process using Matlab. I do that by loading each file using the 'load(filename)' function. Howeever, I 've noticed that some of the files are incomplete and therefore the number of columns in the last line are not consistent with the rest of the rows in a given file. So what I'd like to do is load the incomplete files to only a certain number of rows (ie to the row number that is complete).
>
> So for ex if the original file size is : 1000 rows x 1000 columns (the real numbers are much much larger), I want to load the file to 999 rows x 1000 columns since the 1000th row is corrupt. Is there any way I could do this in Matlab. One option would be to open each corrupt ASCII file and delete the last row manually but I have >500 files! So wondered if there was a way of doing this on my script file?

If you know the number of lines in advance, TEXTSCAN can be
used to read a specified number of lines.

If you don't know the number of lines in advance, I would have
read each line, one by one, and parsed them to see if they are
complete.

Rune