From: Dmitry on
I'm trying to take a variably sized data file with a variable sized header and turn it into two workable pieces of data, a textdata and a normal data, and I can't use the importdata or UIimportdata commands.

My solution so far has been to parse the data file looking for the end of header mark, '*END*', and then separate the header and the data into two different cells (header and data). The only problem is that now I have to separate my data, with an X amount of columns, into their own column in the data table.

I was hoping that the solution may have lied in the command, textscan(), but in order to get the number of columns set up correctly, you need to have a string with the number of identifiers there will be, eg. textscan( fid, '%n %n %n %n %n') for a data file with 5 columns.

This left me with the only option of throwing all the data underneath the header, in string form, into a cell. Now I am stuck with a cell full of data strings, with the numbers separated by whitespace, and I need to separate the numbers in the data strings.

Any help?
From: us on
"Dmitry " <beletsky(a)umich.edu> wrote in message <hss4hu$chq$1(a)fred.mathworks.com>...
> I'm trying to take a variably sized data file with a variable sized header and turn it into two workable pieces of data, a textdata and a normal data, and I can't use the importdata or UIimportdata commands.
>
> My solution so far has been to parse the data file looking for the end of header mark, '*END*', and then separate the header and the data into two different cells (header and data). The only problem is that now I have to separate my data, with an X amount of columns, into their own column in the data table.
>
> I was hoping that the solution may have lied in the command, textscan(), but in order to get the number of columns set up correctly, you need to have a string with the number of identifiers there will be, eg. textscan( fid, '%n %n %n %n %n') for a data file with 5 columns.
>
> This left me with the only option of throwing all the data underneath the header, in string form, into a cell. Now I am stuck with a cell full of data strings, with the numbers separated by whitespace, and I need to separate the numbers in the data strings.
>
> Any help?

not without any real data, eg,
- a small exemplary piece of your data file...
- the output you want to see...

us
From: Dmitry on
"us " <us(a)neurol.unizh.ch> wrote in message <hss6up$min$1(a)fred.mathworks.com>...
> "Dmitry " <beletsky(a)umich.edu> wrote in message <hss4hu$chq$1(a)fred.mathworks.com>...
> > I'm trying to take a variably sized data file with a variable sized header and turn it into two workable pieces of data, a textdata and a normal data, and I can't use the importdata or UIimportdata commands.
> >
> > My solution so far has been to parse the data file looking for the end of header mark, '*END*', and then separate the header and the data into two different cells (header and data). The only problem is that now I have to separate my data, with an X amount of columns, into their own column in the data table.
> >
> > I was hoping that the solution may have lied in the command, textscan(), but in order to get the number of columns set up correctly, you need to have a string with the number of identifiers there will be, eg. textscan( fid, '%n %n %n %n %n') for a data file with 5 columns.
> >
> > This left me with the only option of throwing all the data underneath the header, in string form, into a cell. Now I am stuck with a cell full of data strings, with the numbers separated by whitespace, and I need to separate the numbers in the data strings.
> >
> > Any help?
>
> not without any real data, eg,
> - a small exemplary piece of your data file...
> - the output you want to see...
>
> us

An example of the file itself looks like:

#header
#header
#header
*more header
*more header
*more header
*END*
10 11 12 13 14 15
20 21 22 23 24 25
30 31 32 33 34 35
75 74 73 72 71 70

After processing, the head is in it's own cell. The data file is in a cell that looks like:

column 1
1- '10 11 12 13 14 15'
2- '20 21 22 23 24 25'
3- '30 31 32 33 34 35'
4- '75 74 73 72 71 70'

What I want to do is separate these strings into their own numbers and their own columns, so column 1 would have 10, 20, 30, 75, column 2 would have 11, 21, 31, 74, and so on.

My largest issue would be just separating the strings, because if I can do that, I could simply use a for loop to put them all back into a data table.
From: Walter Roberson on
Dmitry wrote:
> I'm trying to take a variably sized data file with a variable sized
> header and turn it into two workable pieces of data, a textdata and a
> normal data, and I can't use the importdata or UIimportdata commands.
>
> My solution so far has been to parse the data file looking for the end
> of header mark, '*END*', and then separate the header and the data into
> two different cells (header and data). The only problem is that now I
> have to separate my data, with an X amount of columns, into their own
> column in the data table.

If you read the text into a single string, newlines and all, then str2num()
will convert it into an array of the correct size. You can use fread() with
'*char' as the precision to read the rest of the file into a string.
From: Dmitry on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hss7ql$59c$1(a)canopus.cc.umanitoba.ca>...
> Dmitry wrote:
> > I'm trying to take a variably sized data file with a variable sized
> > header and turn it into two workable pieces of data, a textdata and a
> > normal data, and I can't use the importdata or UIimportdata commands.
> >
> > My solution so far has been to parse the data file looking for the end
> > of header mark, '*END*', and then separate the header and the data into
> > two different cells (header and data). The only problem is that now I
> > have to separate my data, with an X amount of columns, into their own
> > column in the data table.
>
> If you read the text into a single string, newlines and all, then str2num()
> will convert it into an array of the correct size. You can use fread() with
> '*char' as the precision to read the rest of the file into a string.

Bump as I'm still unable to make this work. I feel like this is on the right track though. However, when I run the fread() with *char, it still spits out the entire file instead of separating it.