X-Received: by 10.224.59.205 with SMTP id m13mr5059951qah.7.1371678284485;
        Wed, 19 Jun 2013 14:44:44 -0700 (PDT)
X-Received: by 10.50.13.105 with SMTP id g9mr1026491igc.9.1371678284447; Wed,
 19 Jun 2013 14:44:44 -0700 (PDT)
Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!ottix-news.ottix.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!j2no873418qak.0!news-out.google.com!y6ni3510qax.0!nntp.google.com!j2no873414qak.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.soft-sys.matlab
Date: Wed, 19 Jun 2013 14:44:44 -0700 (PDT)
In-Reply-To: <kpt30e$928$1@speranza.aioe.org>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=202.78.152.105;
 posting-account=qPexFwkAAABOl8VUndE6Jm-9Z5z_fSpR
NNTP-Posting-Host: 202.78.152.105
References: <kpo59r$4ra$1@newscl01ah.mathworks.com> <kpq7fb$i95$1@speranza.aioe.org>
 <kpt17b$ie3$1@newscl01ah.mathworks.com> <kpt30e$928$1@speranza.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <87f787b0-17ab-4f75-9c0a-9f5dc71ca781@googlegroups.com>
Subject: Re: read numerical text file by fixed column width, no delimiters
From: TideMan <mulgor@gmail.com>
Injection-Date: Wed, 19 Jun 2013 21:44:44 +0000
Content-Type: text/plain; charset=ISO-8859-1
Lines: 89
Xref: news.mathworks.com comp.soft-sys.matlab:797844

On Thursday, June 20, 2013 8:06:42 AM UTC+12, dpb wrote:
> On 6/19/2013 2:36 PM, Kristin wrote:
> 
> ...
> 
> 
> 
> OK, here's a very rough, not terribly user=friendly outline, but should 
> 
> get the job done...
> 
> 
> 
> program tentoeleven
> 
>    character(len=132):: fold, fnew  ! A filename for old, new file
> 
>    real              :: v(8)        ! Data array of 8 floats
> 
> 
> 
>    read(*,*) fold                   ! It'll wait for you...
> 
>    open(11,file=fold,action='read',status='old')
> 
> 
> 
>    read(*,*) fnew                   ! It'll wait for you...
> 
>    open(12,file=fnew,action='write',status='new')
> 
> 
> 
>    ios=0
> 
>    do while(ios.eq.0)
> 
>      read(11,'(F10.4)',iostat=ios) v ! read the old file F10.4
> 
>      write(12,'(F11.4)') v           ! F11.4 will insert space delimiter
> 
>    end do
> 
> 
> 
>    close(11)
> 
>    close(12)
> 
> end
> 
> 
> 
> Will continue 'til EOF condition on the old file at which time the 
> 
> IOSTATUS variable will become <0.  Of course, other errors will also 
> 
> abort, but one presumes the files are otherwise, clean.
> 
> 
> 
> --

Here's an alternative that can be run within Matlab using:
dos(['tentoeleven ' infile ' ' outfile])
where infile and outfile are strings with the filenames.

program tentoeleven
   character(len=132):: fold, fnew  ! A filename for old, new file
   real              :: v(8)        ! Data array of 8 floats
   integer           :: na          ! No of args on command line
   integer           :: ios         ! Error code for read

   na=iargc()
   if(na < 2)stop 'Must specify infile and outfile on command line'
   call getarg(1,fold)
   call getarg(2,fnew)

   open(11,file=fold,action='read',status='old')
   open(12,file=fnew,action='write',status='new')

   ios=0
   do while(ios.eq.0)
     read(11,'(F10.4)',iostat=ios) v ! read the old file F10.4
     write(12,'(F11.4)') v           ! F11.4 will insert space delimiter
   end do

   close(11)
   close(12)
end