<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541</link>
    <title>MATLAB Central Newsreader - how to read a file skipping all the text lines</title>
    <description>Feed for thread: how to read a file skipping all the text lines</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>Wed, 30 Jul 2008 23:58:01 -0400</pubDate>
      <title>how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#446444</link>
      <author>Kushagra Mittal</author>
      <description>Hi&lt;br&gt;
I want to read a ASCII file (given below). I only want to&lt;br&gt;
read the numerical data in the form of a matrix and skip all&lt;br&gt;
other text lines and the last character in the file which is ')'&lt;br&gt;
&lt;br&gt;
Please suggest me how to do it? &lt;br&gt;
&lt;br&gt;
Thanks very much,&lt;br&gt;
Kushagra&lt;br&gt;
&lt;br&gt;
----------------------------&lt;br&gt;
File :&lt;br&gt;
----------------------------&lt;br&gt;
&lt;br&gt;
(title &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
(labels &quot;Position&quot; &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
&lt;br&gt;
((xy/key/label &quot;line-14&quot;)&lt;br&gt;
-0.0374802	0&lt;br&gt;
-0.0349168	0&lt;br&gt;
-0.032392	0&lt;br&gt;
-0.0297849	0&lt;br&gt;
-0.02719	0&lt;br&gt;
-0.0245914	0&lt;br&gt;
-0.0220529	0&lt;br&gt;
-0.0195992	0&lt;br&gt;
-0.0171695	0&lt;br&gt;
)</description>
    </item>
    <item>
      <pubDate>Thu, 31 Jul 2008 06:07:15 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#446488</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g6qv69$4cu$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Kushagra Mittal &amp;lt;kmittal@ymail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;I want to read a ASCII file (given below). I only want to&lt;br&gt;
&amp;gt;read the numerical data in the form of a matrix and skip all&lt;br&gt;
&amp;gt;other text lines and the last character in the file which is ')'&lt;br&gt;
&lt;br&gt;
&amp;gt;Please suggest me how to do it? &lt;br&gt;
&lt;br&gt;
Use textscan(), telling it that ( and ) are comment characters.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;You may comand nature to the extent only in which you are willing to&lt;br&gt;
&amp;nbsp;&amp;nbsp;obey her.&quot;                                  -- Walter Russell</description>
    </item>
    <item>
      <pubDate>Tue, 19 Aug 2008 07:09:02 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#596269</link>
      <author>Andres </author>
      <description>&quot;Miroslav Balda&quot; &amp;lt;balda.nospam@cdm.it.cas.cz&amp;gt; wrote in &lt;br&gt;
message &amp;lt;g8dile$doh$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Kushagra Mittal&quot; &amp;lt;kmittal@ymail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g6qv69$4cu$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi&lt;br&gt;
&amp;gt; &amp;gt; I want to read a ASCII file (given below). I only want &lt;br&gt;
to&lt;br&gt;
&amp;gt; &amp;gt; read the numerical data in the form of a matrix and &lt;br&gt;
skip all&lt;br&gt;
&amp;gt; &amp;gt; other text lines and the last character in the file &lt;br&gt;
which&lt;br&gt;
&amp;gt; is ')'&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Please suggest me how to do it? &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks very much,&lt;br&gt;
&amp;gt; &amp;gt; Kushagra&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ----------------------------&lt;br&gt;
&amp;gt; &amp;gt; File :&lt;br&gt;
&amp;gt; &amp;gt; ----------------------------&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; (title &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
&amp;gt; &amp;gt; (labels &quot;Position&quot; &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ((xy/key/label &quot;line-14&quot;)&lt;br&gt;
&amp;gt; &amp;gt; -0.0374802	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0349168	0&lt;br&gt;
&amp;gt; &amp;gt; -0.032392	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0297849	0&lt;br&gt;
&amp;gt; &amp;gt; -0.02719	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0245914	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0220529	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0195992	0&lt;br&gt;
&amp;gt; &amp;gt; -0.0171695	0&lt;br&gt;
&amp;gt; &amp;gt; )&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I think that your file is good to be read by the function&lt;br&gt;
&amp;gt; txt2mat from File Exchange, Id 18430.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Mira&lt;br&gt;
&lt;br&gt;
I agree. One of the txt2mat-solutions would be to use &lt;br&gt;
the 'BadLineString' argument to ignore all lines containing &lt;br&gt;
a ')' :&lt;br&gt;
&lt;br&gt;
filename = 'C:\myfile.txt';&lt;br&gt;
data = txt2mat(filename,'BadLineString',{')'});&lt;br&gt;
&lt;br&gt;
Best regards&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Mon, 18 Aug 2008 23:51:56 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#575520</link>
      <author>beginner1.mat@hotmail.com</author>
      <description>On Jul 30, 11:07=A0pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; In article &amp;lt;g6qv69$4c...@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Kushagra Mittal &amp;lt;kmit...@ymail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;I want to read a ASCII file (given below). I only want to&lt;br&gt;
&amp;gt; &amp;gt;read the numerical data in the form of a matrix andskipall&lt;br&gt;
&amp;gt; &amp;gt;other textlinesand the last character in the file which is ')'&lt;br&gt;
&amp;gt; &amp;gt;Please suggest me how to do it?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Usetextscan(), telling it that ( and ) are comment characters.&lt;br&gt;
&lt;br&gt;
Is there a way to have more than one comment character?  Say, one of&lt;br&gt;
the lines starts with &quot;Titles&quot; and the other with &quot;Lables&quot;.  Can you&lt;br&gt;
set commentStyle to skip both of those lines?&lt;br&gt;
fid =3D fopen('data.txt');&lt;br&gt;
Data =3D textscan(fid, '%f%f', 'commentStyle', ['Titles', 'Lables']);%&lt;br&gt;
This doesn't work, but wondering what would???&lt;br&gt;
fclose(fid);&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Tue, 19 Aug 2008 00:17:03 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#575524</link>
      <author>Paul </author>
      <description>beginner1.mat@hotmail.com wrote in message&lt;br&gt;
&amp;lt;94268f3f-48b4-45af-b762-be0eda8c3364@x16g2000prn.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Jul 30, 11:07=A0pm, rober...@ibd.nrc-cnrc.gc.ca (Walter&lt;br&gt;
Roberson)&lt;br&gt;
&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; In article &amp;lt;g6qv69$4c...@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Kushagra Mittal &amp;lt;kmit...@ymail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;I want to read a ASCII file (given below). I only want to&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;read the numerical data in the form of a matrix andskipall&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;other textlinesand the last character in the file which&lt;br&gt;
is ')'&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;Please suggest me how to do it?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Usetextscan(), telling it that ( and ) are comment&lt;br&gt;
characters.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there a way to have more than one comment character? &lt;br&gt;
Say, one of&lt;br&gt;
&amp;gt; the lines starts with &quot;Titles&quot; and the other with&lt;br&gt;
&quot;Lables&quot;.  Can you&lt;br&gt;
&amp;gt; set commentStyle to skip both of those lines?&lt;br&gt;
&amp;gt; fid =3D fopen('data.txt');&lt;br&gt;
&amp;gt; Data =3D textscan(fid, '%f%f', 'commentStyle', ['Titles',&lt;br&gt;
'Lables']);%&lt;br&gt;
&amp;gt; This doesn't work, but wondering what would???&lt;br&gt;
&amp;gt; fclose(fid);&lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
Try putting Titles and Lables in a cell array and see if&lt;br&gt;
that works.</description>
    </item>
    <item>
      <pubDate>Tue, 19 Aug 2008 02:03:29 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#575530</link>
      <author>beginner1.mat@hotmail.com</author>
      <description>On Aug 18, 5:17=A0pm, &quot;Paul &quot; &amp;lt;p...@ceri.memphis.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; beginner1....@hotmail.com wrote in message&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;94268f3f-48b4-45af-b762-be0eda8c3...@x16g2000prn.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; On Jul 30, 11:07=3DA0pm, rober...@ibd.nrc-cnrc.gc.ca (Walter&lt;br&gt;
&amp;gt; Roberson)&lt;br&gt;
&amp;gt; &amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; In article &amp;lt;g6qv69$4c...@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Kushagra Mittal &amp;lt;kmit...@ymail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;I want to read a ASCII file (given below). I only want to&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;read the numerical data in the form of a matrix andskipall&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;other textlinesand the last character in the file which&lt;br&gt;
&amp;gt; is ')'&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt;Please suggest me how to do it?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Usetextscan(), telling it that ( and ) are comment&lt;br&gt;
&amp;gt; characters.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Is there a way to have more than one comment character?&lt;br&gt;
&amp;gt; Say, one of&lt;br&gt;
&amp;gt; &amp;gt; the lines starts with &quot;Titles&quot; and the other with&lt;br&gt;
&amp;gt; &quot;Lables&quot;. =A0Can you&lt;br&gt;
&amp;gt; &amp;gt; set commentStyle to skip both of those lines?&lt;br&gt;
&amp;gt; &amp;gt; fid =3D3D fopen('data.txt');&lt;br&gt;
&amp;gt; &amp;gt; Data =3D3D textscan(fid, '%f%f', 'commentStyle', ['Titles',&lt;br&gt;
&amp;gt; 'Lables']);%&lt;br&gt;
&amp;gt; &amp;gt; This doesn't work, but wondering what would???&lt;br&gt;
&amp;gt; &amp;gt; fclose(fid);&lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Try putting Titles and Lables in a cell array and see if&lt;br&gt;
&amp;gt; that works.&lt;br&gt;
&lt;br&gt;
It didn't...seems like that is used for start and stop when put into a&lt;br&gt;
cell array.</description>
    </item>
    <item>
      <pubDate>Tue, 19 Aug 2008 04:37:02 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#575541</link>
      <author>Miroslav Balda</author>
      <description>&quot;Kushagra Mittal&quot; &amp;lt;kmittal@ymail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6qv69$4cu$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi&lt;br&gt;
&amp;gt; I want to read a ASCII file (given below). I only want to&lt;br&gt;
&amp;gt; read the numerical data in the form of a matrix and skip all&lt;br&gt;
&amp;gt; other text lines and the last character in the file which&lt;br&gt;
is ')'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Please suggest me how to do it? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks very much,&lt;br&gt;
&amp;gt; Kushagra&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ----------------------------&lt;br&gt;
&amp;gt; File :&lt;br&gt;
&amp;gt; ----------------------------&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (title &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
&amp;gt; (labels &quot;Position&quot; &quot;Mean Volume fraction (air) &quot;)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ((xy/key/label &quot;line-14&quot;)&lt;br&gt;
&amp;gt; -0.0374802	0&lt;br&gt;
&amp;gt; -0.0349168	0&lt;br&gt;
&amp;gt; -0.032392	0&lt;br&gt;
&amp;gt; -0.0297849	0&lt;br&gt;
&amp;gt; -0.02719	0&lt;br&gt;
&amp;gt; -0.0245914	0&lt;br&gt;
&amp;gt; -0.0220529	0&lt;br&gt;
&amp;gt; -0.0195992	0&lt;br&gt;
&amp;gt; -0.0171695	0&lt;br&gt;
&amp;gt; )&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
&lt;br&gt;
I think that your file is good to be read by the function&lt;br&gt;
txt2mat from File Exchange, Id 18430.&lt;br&gt;
&lt;br&gt;
Mira</description>
    </item>
    <item>
      <pubDate>Tue, 19 Aug 2008 04:37:02 -0400</pubDate>
      <title>Re: how to read a file skipping all the text lines</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173541#575542</link>
      <author>Paul </author>
      <description>beginner1.mat@hotmail.com wrote in message&lt;br&gt;
&amp;lt;7f58cd55-3107-4b4e-8b5b-bee2840f17d5@r15g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Aug 18, 5:17=A0pm, &quot;Paul &quot; &amp;lt;p...@ceri.memphis.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; beginner1....@hotmail.com wrote in message&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;lt;94268f3f-48b4-45af-b762-be0eda8c3...@x16g2000prn.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; On Jul 30, 11:07=3DA0pm, rober...@ibd.nrc-cnrc.gc.ca&lt;br&gt;
(Walter&lt;br&gt;
&amp;gt; &amp;gt; Roberson)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; In article &amp;lt;g6qv69$4c...@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Kushagra Mittal &amp;lt;kmit...@ymail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt;I want to read a ASCII file (given below). I only&lt;br&gt;
want to&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt;read the numerical data in the form of a matrix&lt;br&gt;
andskipall&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt;other textlinesand the last character in the file which&lt;br&gt;
&amp;gt; &amp;gt; is ')'&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt;Please suggest me how to do it?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Usetextscan(), telling it that ( and ) are comment&lt;br&gt;
&amp;gt; &amp;gt; characters.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Is there a way to have more than one comment character?&lt;br&gt;
&amp;gt; &amp;gt; Say, one of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; the lines starts with &quot;Titles&quot; and the other with&lt;br&gt;
&amp;gt; &amp;gt; &quot;Lables&quot;. =A0Can you&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; set commentStyle to skip both of those lines?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fid =3D3D fopen('data.txt');&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Data =3D3D textscan(fid, '%f%f', 'commentStyle',&lt;br&gt;
['Titles',&lt;br&gt;
&amp;gt; &amp;gt; 'Lables']);%&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; This doesn't work, but wondering what would???&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; fclose(fid);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Try putting Titles and Lables in a cell array and see if&lt;br&gt;
&amp;gt; &amp;gt; that works.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It didn't...seems like that is used for start and stop&lt;br&gt;
when put into a&lt;br&gt;
&amp;gt; cell array.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Sorry about that.  &lt;br&gt;
&lt;br&gt;
What about declaring the '(' as a commentStyle and the ')'&lt;br&gt;
as an endOfLine character?  </description>
    </item>
  </channel>
</rss>

