Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!feeder.erje.net!eu.feeder.erje.net!nuzba.szn.dk!pnx.dk!news.stack.nl!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: read numerical text file by fixed column width, no delimiters
Date: Wed, 19 Jun 2013 15:06:42 -0500
Organization: Aioe.org NNTP Server
Lines: 31
Message-ID: <kpt30e$928$1@speranza.aioe.org>
References: <kpo59r$4ra$1@newscl01ah.mathworks.com> <kpq7fb$i95$1@speranza.aioe.org> <kpt17b$ie3$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: jy+QfeYoQFMk8Or4YOj/xQ.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:797834

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.

--