From: us on
"David T" <dtracy85(a)gmail.com> wrote in message <i24tnc$lu3$1(a)fred.mathworks.com>...
> > well... this IS TOUGH(!)...
> >
> > do you have any more information re the anatomy of your pictorial file
> > - the max # of cols...
> > - the length of a whitespace/numeric cell...
> > looking at the original format of your example, they seem to have a length of three
> >
> > us
>
> I just made up the example on here because my data is on another machine.
> The data is in i4 format meaning 4 spaces per grid cell. The raw data is 90 lines by 720 columns which will be processed to 90 x 180 (720/4). So every 4 spaces should be a new cell. The cells that are skipped are cases where 4 white spaces exist in a row.
>
> I've tried doing a find/replace in a basic editor and replaced all empty spaces with 0 and that works, however, i'm trying to automate the process because i have several files which need to be imported.
>
> I've tried using different delimiters as well with no avail.
>
> Thanks again for all the help!

ok... let's create a simple example
(note: look at it using the ORIGINAL VIEW to see the propper formatting)

% foo.txt
1 2 3 4 5
10 11 12 13 14 15
% end of foo.txt

one of the solutions

fnam='foo.txt';
s=textread(fnam,'%s','delimiter','\n','whitespace','');
r=regexprep(s,'\s{4,4}',' 0'); % <- three SPACEs + '0'
r=cat(1,r{:})
%{
% r =
0 0 1 2 3 0 0 4 5 0 0
0 0 10 11 12 0 0 13 14 0 15
%}

us
From: David T on
THanks for all the help.

I tried what you suggested and it didn't quiet work like i was hoping it would. Due to time constraints i think i'm just going to bite the bullet and do a find replace for the files so i can start processing them. Thanks again for all the help

dt