From: David T on 20 Jul 2010 14:29 I am trying to import several files that are 90 lines by 720 Columns (90X180 in i4 format). The data is sporadic and the file contains many blank spaces. When I import the file using textread, even with a specified format, it clumps all of the data to the left side of the matrix. If the data was simply numeric this would not be an issue, but it is spatially defined as well so its location within the matrix must be retained. I've tried using the whitespaces and emptyvalue property but it still clumps the data. If anyone hows of a way to retain all the spaces or replace any empty spaces with zeros that would be very helpful code: ...format.. = textread('filename',form,90,'whitespaces', ' '); or ...format.. = textread('filename',form,90,'empyvalues', 0); Thank you in advance for you help!
From: us on 20 Jul 2010 14:42 "David T" <dtracy85(a)gmail.com> wrote in message <i24pu2$d75$1(a)fred.mathworks.com>... > I am trying to import several files that are 90 lines by 720 Columns (90X180 in i4 format). The data is sporadic and the file contains many blank spaces. > > When I import the file using textread, even with a specified format, it clumps all of the data to the left side of the matrix. If the data was simply numeric this would not be an issue, but it is spatially defined as well so its location within the matrix must be retained. I've tried using the whitespaces and emptyvalue property but it still clumps the data. > > If anyone hows of a way to retain all the spaces or replace any empty spaces with zeros that would be very helpful > > code: > > ..format.. = textread('filename',form,90,'whitespaces', ' '); > > or > > ..format.. = textread('filename',form,90,'empyvalues', 0); > > > > Thank you in advance for you help! can you show a SMALL yet exemplary section of one of your files(?)... us
From: David T on 20 Jul 2010 15:11 > can you show a SMALL yet exemplary section of one of your files(?)... > > us of course and thanks for the reply: 4 4 4 5 4 4 4 4 4 4 5 4 5 4 4 4 5 4 4 4 4 when it is imported using the above mentioned code it will look like this 4 4 4 5 4 4 4 4 4 4 5 4 5 40000000 4 4 5 4 4 4 4000000000000000000 with all of the spaces missing. each number is in its own cell but all the cells are clumped. my goal is... 0 0 0 4 4 4 5 4 4 4 0 0 0 0 0 4 4 4 5 4 5 4 0 0 4 0 4 5 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 again, with each number in its own cell. Thanks again!
From: us on 20 Jul 2010 15:24 "David T" <dtracy85(a)gmail.com> wrote in message <i24sc9$n1s$1(a)fred.mathworks.com>... > > can you show a SMALL yet exemplary section of one of your files(?)... > > > > us > > of course and thanks for the reply: > > 4 4 4 5 4 4 4 4 4 4 5 4 5 4 > 4 4 5 4 4 4 4 > > when it is imported using the above mentioned code it will look like this > > > 4 4 4 5 4 4 4 4 4 4 5 4 5 40000000 > 4 4 5 4 4 4 4000000000000000000 > > with all of the spaces missing. each number is in its own cell but all the cells are clumped. > > my goal is... > > 0 0 0 4 4 4 5 4 4 4 0 0 0 0 0 4 4 4 5 4 5 4 > 0 0 4 0 4 5 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 > > again, with each number in its own cell. > > Thanks again! 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
From: David T on 20 Jul 2010 15:34
> 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! |