<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800</link>
    <title>MATLAB Central Newsreader - import uneven data file</title>
    <description>Feed for thread: import uneven data file</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>Fri, 23 May 2008 13:10:19 -0400</pubDate>
      <title>import uneven data file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800#433691</link>
      <author>AMK</author>
      <description>Hi,&lt;br&gt;
I would like to import a comma delimited file that takes the form:&lt;br&gt;
&lt;br&gt;
file1:&lt;br&gt;
115,1,2,3,4,5&lt;br&gt;
101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&lt;br&gt;
Does a matlab command exist to do this?&lt;br&gt;
&lt;br&gt;
ie. convert on-the-fly to this so the workspace can handle it?&lt;br&gt;
115,1,2,3,4,5,nan,nan,nan,nan&lt;br&gt;
101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&lt;br&gt;
Then create a variable of just the 115 rows and a variable of just the 101 rows?&lt;br&gt;
&lt;br&gt;
x1 = 115,1,2,3,4,5,&lt;br&gt;
x2 = 101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
AMK</description>
    </item>
    <item>
      <pubDate>Fri, 23 May 2008 13:28:01 -0400</pubDate>
      <title>Re: import uneven data file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800#433692</link>
      <author>Jos </author>
      <description>AMK &amp;lt;kennaster@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;7282774.1211548249862.JavaMail.jakarta@nitrogen.mathforum.org&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; I would like to import a comma delimited file that takes&lt;br&gt;
the form:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; file1:&lt;br&gt;
&amp;gt; 115,1,2,3,4,5&lt;br&gt;
&amp;gt; 101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does a matlab command exist to do this?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
D1 = textread('data.txt','%f','delimiter',',')&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ie. convert on-the-fly to this so the workspace can handle it?&lt;br&gt;
&amp;gt; 115,1,2,3,4,5,nan,nan,nan,nan&lt;br&gt;
&amp;gt; 101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
D2 =  load('data.txt')&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Then create a variable of just the 115 rows and a variable&lt;br&gt;
of just the 101 rows?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x1 = 115,1,2,3,4,5,&lt;br&gt;
&amp;gt; x2 = 101,1,2,3,4,5,6,7,8,9&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
D1 will not be trivial.&lt;br&gt;
D2 will be relatively easy:&lt;br&gt;
&lt;br&gt;
q = isnan(D2) ;&lt;br&gt;
x1 = D2(1,q(1,:)) &lt;br&gt;
x2 = ...&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos</description>
    </item>
    <item>
      <pubDate>Fri, 23 May 2008 17:01:19 -0400</pubDate>
      <title>Re: import uneven data file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800#433727</link>
      <author>AMK</author>
      <description>Hi and thank for the reply,&lt;br&gt;
&lt;br&gt;
But I'm not clear.  For clarification, the data file is large, hundreds of thousands of rows.  101 rows are recorded every minute, and 115 rows are recorded every 15 minutes.&lt;br&gt;
&lt;br&gt;
I tried it with just two lines and the D1 command seems to drop everything in a single column.  D2 errors our with &quot;??? Error using ==&amp;gt; load&lt;br&gt;
Number of columns on line 1 of ASCII file N:\2008\fiberOpticsAirshed\ml_scripts\finalScripts\data.txt&lt;br&gt;
must be the same as previous lines.&quot;, which is my continued problem.  &lt;br&gt;
&lt;br&gt;
Am I misunderstanding your solution?&lt;br&gt;
&lt;br&gt;
Thanks again,&lt;br&gt;
AMK</description>
    </item>
    <item>
      <pubDate>Fri, 23 May 2008 17:04:36 -0400</pubDate>
      <title>Re: import uneven data file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800#433728</link>
      <author>AMK</author>
      <description>And just to be clear, the 115 labeled rows have fewer columns than the 101 rows.&lt;br&gt;
&lt;br&gt;
AMK</description>
    </item>
    <item>
      <pubDate>Fri, 23 May 2008 20:28:02 -0400</pubDate>
      <title>Re: import uneven data file</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/169800#433757</link>
      <author>Andres </author>
      <description>AMK &amp;lt;kennaster@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;21277086.1211562307457.JavaMail.jakarta@nitrogen.mathforum.org&amp;gt;...&lt;br&gt;
&amp;gt; And just to be clear, the 115 labeled rows have fewer&lt;br&gt;
columns than the 101 rows.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; AMK&lt;br&gt;
&lt;br&gt;
So there are two distinct types of rows that you can tell by&lt;br&gt;
there first element? I.e. a rare one beginning with 115&lt;br&gt;
('type A') and the other with 101 ('type B')?! And you know&lt;br&gt;
the number of elements of each row type, or at least that&lt;br&gt;
the type B rows always have N=4 more elements then the type&lt;br&gt;
A ones?!&lt;br&gt;
Then there is a fast way with txt2mat from the file exchange&lt;br&gt;
(sorry I'm biased to it, but I'm the author)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
FileOrPath = 'c:\mydata'; &lt;br&gt;
&lt;br&gt;
A = txt2mat(FileOrPath,'ReplaceExpr',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{{'115',[repmat('NaN,',1,4) '115']}});&lt;br&gt;
&lt;br&gt;
q = isnan(A(:,1)) ;&lt;br&gt;
&lt;br&gt;
x1 = A(find(q),5:end);&lt;br&gt;
x2 = A(find(~q),:);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
txt2mat can 'natively' handle files with different row&lt;br&gt;
lengths as well (see it's help), but I suppose using the&lt;br&gt;
replacement trick above will speed things up. Feel free to&lt;br&gt;
contact me (via the fex form) if you think the import takes&lt;br&gt;
too long, or if any problems occur.&lt;br&gt;
There are certainly many other solutions.&lt;br&gt;
Best wishes&lt;br&gt;
Andres</description>
    </item>
  </channel>
</rss>

