Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: file length
Date: Wed, 3 Jun 2009 13:46:44 -0400
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <h06ctf$er4$1@fred.mathworks.com>
References: <h05vlj$csf$1@fred.mathworks.com> <h06437$kts$1@online.de> <h0663p$4te$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1244051183 15204 144.212.105.187 (3 Jun 2009 17:46:23 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 3 Jun 2009 17:46:23 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:544591



"Dominic " <dcg48@cornell.edu> wrote in message 
news:h0663p$4te$1@fred.mathworks.com...
> Lothar Schmidt <vapooroop@gmx.net> wrote in message 
> <h06437$kts$1@online.de>...
>> Dominic schrieb:
>> > Hi,
>> > I was wondering if anyone knew of a way to find the length (preferably 
>> > the number of rows) in a .dat file without having to load it into 
>> > MATLAB?
>> > Thank you
>>
>> number of bytes you can find as follows:
>>
>> fileinfo=dir('filename.dat');
>> fileinfo.size
>>
>> difficult to guess the number of row separators without reading the
>> file... perhaps meanwhile someone has written crystalball.m and put it
>> in the FEX.
>>
>> Lothar
>
> Is there any way for me to use the number of bytes in the file to deduce 
> the number of data points or something along those lines?

What OS are you using?  If you're on Linux or Solaris (and probably Mac as 
well, though I haven't tried it) call out to the system (SYSTEM, DOS, UNIX, 
or !) and use the wc system function.  This will give you, among other 
information, the newline count for the file.  See "man wc" for more 
information.

-- 
Steve Lord
slord@mathworks.com