<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812</link>
    <title>MATLAB Central Newsreader - quick question about 'textscan'</title>
    <description>Feed for thread: quick question about 'textscan'</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 14 Sep 2009 17:15:06 -0400</pubDate>
      <title>quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680066</link>
      <author>Apurva Dave</author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I'm using textscan to read some tab-delimited data. I want to ignore the metadata as well as some comments. I'm using the following syntax, but I'm getting an 'unknown option' error when I try to use 'commentstyle':&lt;br&gt;
&lt;br&gt;
fid = fopen('P980413A.DAT');&lt;br&gt;
&lt;br&gt;
textfile = textscan(fid, '%f', 28, 'delimiter','	', ...&lt;br&gt;
	'commentstyle', {'/begin_header /end_header@'}, ...&lt;br&gt;
	'commentstyle', '/begin_data', ...&lt;br&gt;
	'commentstyle', '/end_data@');&lt;br&gt;
&lt;br&gt;
fclose(fid);&lt;br&gt;
&lt;br&gt;
As far as I can tell, I've entered it all correctly. Parameters are not case-sensitive, although I also tried different versions just to check. Is this a bug in the matlab? I tried restarting. &lt;br&gt;
&lt;br&gt;
'headerlines' isn't a good alternative for me, b/c the metadata for each data file aren't uniform. In any case I still need to find a way to ignore comments interspersed through the file. Any thoughts?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Apurva</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 17:30:33 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680072</link>
      <author>dpb</author>
      <description>Apurva Dave wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm using textscan to read some tab-delimited data. I want to&lt;br&gt;
&amp;gt; ignore the metadata as well as some comments. I'm using the following&lt;br&gt;
&amp;gt; syntax,but I'm getting an 'unknown option' error when I try to use 'commentstyle':&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; fid = fopen('P980413A.DAT');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; textfile = textscan(fid, '%f', 28, 'delimiter','	', ...&lt;br&gt;
&amp;gt; 	'commentstyle', {'/begin_header /end_header@'}, ...&lt;br&gt;
&amp;gt; 	'commentstyle', '/begin_data', ...&lt;br&gt;
&amp;gt; 	'commentstyle', '/end_data@');&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
textscan() postdates my version and don't have time to look at web doc &lt;br&gt;
right now, but does it indicate can have multiple 'commentstyle' entries &lt;br&gt;
as allowable syntax?  That's unusual at least w/ any ML function I'm &lt;br&gt;
aware of....&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 17:48:19 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680077</link>
      <author>Apurva Dave</author>
      <description>yup, that would be my problem. thank you!&lt;br&gt;
&lt;br&gt;
does anyone have a suggestion for how to deal with metadata and comments by calling distinct paramaters (ie. without trying to call 'commentstyle' multiple times). once again, 'headerlines' isn't a good option for me b/c my metadata vary from file to file.&lt;br&gt;
&lt;br&gt;
thanks,&lt;br&gt;
apurva</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 17:59:54 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680080</link>
      <author>Rune Allnor</author>
      <description>On 14 Sep, 19:48, &quot;Apurva Dave&quot; &amp;lt;|remove.this|apurva.dave|&lt;br&gt;
remove.th...@duke.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; yup, that would be my problem. thank you!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; does anyone have a suggestion for how to deal with metadata and comments by calling distinct paramaters (ie. without trying to call 'commentstyle' multiple times). once again, 'headerlines' isn't a good option for me b/c my metadata vary from file to file.&lt;br&gt;
&lt;br&gt;
Don't use TEXTSCAN.&lt;br&gt;
&lt;br&gt;
It seems your data might be complicated enough to warrant&lt;br&gt;
you writing a dedicated parser.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 18:33:04 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680084</link>
      <author>Apurva Dave</author>
      <description>Thanks Rune, but that seems like something that's beyond my abilities right now...&lt;br&gt;
&lt;br&gt;
Is there anyway I can make edits to my data files? E.g. within a loop, open each data file with read/write permissions, find and remove all metadata and comments? I know it's possible to fopen text files in read/write mode, but I don't know how to proceed from there...&lt;br&gt;
&lt;br&gt;
I have ~200 data files, so opening them up in an editor and making changes myself is not an option...&lt;br&gt;
&lt;br&gt;
apurva</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 18:49:55 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680086</link>
      <author>Rune Allnor</author>
      <description>On 14 Sep, 20:33, &quot;Apurva Dave&quot; &amp;lt;|remove.this|apurva.dave|&lt;br&gt;
remove.th...@duke.edu&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; Is there anyway I can make edits to my data files? E.g. within a loop, open each data file with read/write permissions, find and remove all metadata and comments?&lt;br&gt;
&lt;br&gt;
Yes, there is: Write a parser.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 20:22:17 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680102</link>
      <author>Apurva Dave</author>
      <description>ok, will give it a shot. thanks!&lt;br&gt;
apurva</description>
    </item>
    <item>
      <pubDate>Mon, 14 Sep 2009 21:33:01 -0400</pubDate>
      <title>Re: quick question about 'textscan'</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/260812#680113</link>
      <author>Andres </author>
      <description>It looks like you (just) want to read numerical data with a variable number of header lines. It may be worth giving txt2mat from the mathworks file exchange a try.</description>
    </item>
  </channel>
</rss>

