Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Data Import/Read Question
Replies: 7   Last Post: May 2, 2014 12:36 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: Data Import/Read Question
Posted: May 1, 2014 4:05 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Friday, May 2, 2014 7:22:53 AM UTC+12, cabrego wrote:
> TideMan <mulgor@gmail.com> wrote in message <1c180e8a-f08f-4b14-afd9-2012ddf8985e@googlegroups.com>...
>

> > On Thursday, May 1, 2014 6:59:09 AM UTC+12, cabrego wrote:
>
> > > I've done several variations of batch file imports but this file format has thrown me for a loop. Any tips on how to attack this?
>
> > >
>
> > >
>
> > >
>
> > > header
>
> > >
>
> > > string1: val1, string2: string3, string4: val2 string5 val3 [array1], [ array2], string6
>
> > >
>
> > > .
>
> > >
>
> > > .
>
> > >
>
> > > Footer
>
> >
>
> > Here's one way:
>
> > Read it in to a set of cell arrays as strings separated by commas:
>
> > c=textscan(fid,repmat('%s',1,5),...
>
> > 'headerlines',1,...
>
> > 'delimiter',',');
>
> > then parse each cell array.
>
>
>
> I ran this code,
>
>
>
> fmt=repmat('%s',1,5);
>
> Header=textscan(fid,'%s');
>
> Data=textscan(fid,fmt,'headerlines',1,'delimiter',',');
>
>
>
> Header looks fine, but the Data contained 5 empty cells. Any ideas?


Why did you add the Header= line when you specified 'headerlines',1 in textscan?

If you're going to do it this way, you have to delete 'headerlines',1 and tell textscan to read only one line into Header, otherwise it will read the whole file into Header.

Remove Header= line and try again.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.