<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719</link>
    <title>MATLAB Central Newsreader - how to read text file row/column info</title>
    <description>Feed for thread: how to read text file row/column info</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>Sat, 15 Mar 2008 04:30:04 -0400</pubDate>
      <title>how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421015</link>
      <author>Bruce Eddy</author>
      <description>Hi,&lt;br&gt;
I am trying to read a large .txt file with 5 columns and &lt;br&gt;
over 12000 rows of data.  I'm having trouble getting the &lt;br&gt;
(row, column) numbers right.  The code looks like this;&lt;br&gt;
&lt;br&gt;
loop = 0;&lt;br&gt;
for i = 1:2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;line1 = fgets(fid);&lt;br&gt;
end&lt;br&gt;
while feof(fid) == 0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;loop = loop+1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;line1 = fgets(fid);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Can anyone help?&lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Sat, 15 Mar 2008 09:51:04 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421031</link>
      <author>Pekka </author>
      <description>&quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; I am trying to read a large .txt file with 5 columns and &lt;br&gt;
&amp;gt; over 12000 rows of data.  I'm having trouble getting the &lt;br&gt;
&amp;gt; (row, column) numbers right.  The code looks like this;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; loop = 0;&lt;br&gt;
&amp;gt; for i = 1:2&lt;br&gt;
&amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; while feof(fid) == 0&lt;br&gt;
&amp;gt;     loop = loop+1;&lt;br&gt;
&amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt;     mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;gt;     mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;gt;     mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;gt;     mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;gt;     mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Can anyone help?&lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&lt;br&gt;
Really hard to help much without knowing the structure of &lt;br&gt;
your file. Hard coding the indexing is generally not a good &lt;br&gt;
idea. That will fail if any of the lines has different &lt;br&gt;
length in any of the fields.&lt;br&gt;
&lt;br&gt;
Take a look at &lt;br&gt;
doc textscan &lt;br&gt;
that should read the entire file wthout loops and hard &lt;br&gt;
coded indexing.  </description>
    </item>
    <item>
      <pubDate>Sat, 15 Mar 2008 12:32:08 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421040</link>
      <author>Andres Toennesmann</author>
      <description>&quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; I am trying to read a large .txt file with 5 columns and &lt;br&gt;
&amp;gt; over 12000 rows of data.  I'm having trouble getting the &lt;br&gt;
&amp;gt; (row, column) numbers right.  &lt;br&gt;
&amp;gt; [x]&lt;br&gt;
&lt;br&gt;
Hi Bruce,&lt;br&gt;
&lt;br&gt;
if you want to import numeric data only, (my) txt2mat from&lt;br&gt;
the file exchange should do easily. Maybe &lt;br&gt;
A = txt2mat('c:\data\myfile.txt');&lt;br&gt;
without any further options will work, if your file is quite&lt;br&gt;
ordinarily structured. (You'll assign the columns of A to&lt;br&gt;
your variables afterwards.)&lt;br&gt;
&lt;br&gt;
So much about advertising. If it is mixed data (numbers and&lt;br&gt;
strings), I recommend becoming acquainted to textscan, too.</description>
    </item>
    <item>
      <pubDate>Sat, 15 Mar 2008 16:08:03 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421051</link>
      <author>Bruce Eddy</author>
      <description>&quot;Pekka &quot; &amp;lt;pekka.nospam.kumpulainen@tut.please.fi&amp;gt; wrote in &lt;br&gt;
message &amp;lt;frg668$im6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; I am trying to read a large .txt file with 5 columns &lt;br&gt;
and &lt;br&gt;
&amp;gt; &amp;gt; over 12000 rows of data.  I'm having trouble getting &lt;br&gt;
the &lt;br&gt;
&amp;gt; &amp;gt; (row, column) numbers right.  The code looks like this;&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; loop = 0;&lt;br&gt;
&amp;gt; &amp;gt; for i = 1:2&lt;br&gt;
&amp;gt; &amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; while feof(fid) == 0&lt;br&gt;
&amp;gt; &amp;gt;     loop = loop+1;&lt;br&gt;
&amp;gt; &amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt;     mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;gt; &amp;gt;     mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;gt; &amp;gt;     mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;gt; &amp;gt;     mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;gt; &amp;gt;     mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Can anyone help?&lt;br&gt;
&amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Really hard to help much without knowing the structure of &lt;br&gt;
&amp;gt; your file. Hard coding the indexing is generally not a &lt;br&gt;
good &lt;br&gt;
&amp;gt; idea. That will fail if any of the lines has different &lt;br&gt;
&amp;gt; length in any of the fields.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Take a look at &lt;br&gt;
&amp;gt; doc textscan &lt;br&gt;
&amp;gt; that should read the entire file wthout loops and hard &lt;br&gt;
&amp;gt; coded indexing.  &lt;br&gt;
&amp;gt; &lt;br&gt;
I thought about that after the post.  The file is too big &lt;br&gt;
to show but it is a mix of text and numbers in a columnated &lt;br&gt;
form.  The first column is text with various indenting, the &lt;br&gt;
second column is text, and the last 3 columns are numbers.  &lt;br&gt;
I've seen the limitation of the hard coding but didn't know &lt;br&gt;
of another way.  My goal is to have a code that will read &lt;br&gt;
different text files of the same general format.  Thanks &lt;br&gt;
for the replies.  </description>
    </item>
    <item>
      <pubDate>Sat, 15 Mar 2008 19:49:02 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421082</link>
      <author>Scott Burnside</author>
      <description>&quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message &amp;lt;frgs93&lt;br&gt;
$1ov$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Pekka &quot; &amp;lt;pekka.nospam.kumpulainen@tut.please.fi&amp;gt; wrote &lt;br&gt;
in &lt;br&gt;
&amp;gt; message &amp;lt;frg668$im6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; &amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I am trying to read a large .txt file with 5 columns &lt;br&gt;
&amp;gt; and &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; over 12000 rows of data.  I'm having trouble getting &lt;br&gt;
&amp;gt; the &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; (row, column) numbers right.  The code looks like &lt;br&gt;
this;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; loop = 0;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; for i = 1:2&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; while feof(fid) == 0&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     loop = loop+1;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Can anyone help?&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Really hard to help much without knowing the structure &lt;br&gt;
of &lt;br&gt;
&amp;gt; &amp;gt; your file. Hard coding the indexing is generally not a &lt;br&gt;
&amp;gt; good &lt;br&gt;
&amp;gt; &amp;gt; idea. That will fail if any of the lines has different &lt;br&gt;
&amp;gt; &amp;gt; length in any of the fields.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Take a look at &lt;br&gt;
&amp;gt; &amp;gt; doc textscan &lt;br&gt;
&amp;gt; &amp;gt; that should read the entire file wthout loops and hard &lt;br&gt;
&amp;gt; &amp;gt; coded indexing.  &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; I thought about that after the post.  The file is too big &lt;br&gt;
&amp;gt; to show but it is a mix of text and numbers in a &lt;br&gt;
columnated &lt;br&gt;
&amp;gt; form.  The first column is text with various indenting, &lt;br&gt;
the &lt;br&gt;
&amp;gt; second column is text, and the last 3 columns are &lt;br&gt;
numbers.  &lt;br&gt;
&amp;gt; I've seen the limitation of the hard coding but didn't &lt;br&gt;
know &lt;br&gt;
&amp;gt; of another way.  My goal is to have a code that will read &lt;br&gt;
&amp;gt; different text files of the same general format.  Thanks &lt;br&gt;
&amp;gt; for the replies.  &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Bruce,&lt;br&gt;
&lt;br&gt;
Does your data resemble this?:&lt;br&gt;
&lt;br&gt;
Symbol, Exchange, Date, Time, Bid&lt;br&gt;
CMGI, ARCA, 20040901, 9:31:33, 1.99&lt;br&gt;
GE, ISLAND, 20040901, 9:31:34, 34.63&lt;br&gt;
QQQQ, AUTO, 20040901, 9:31:35, 35.13&lt;br&gt;
&lt;br&gt;
that is, do you have a mix of numeric and text columns of &lt;br&gt;
the same length with a header line and delimters as shown &lt;br&gt;
above?&lt;br&gt;
&lt;br&gt;
If so you can use autotdataread.m from the File Exchange. &lt;br&gt;
It will determine the column type and build the format &lt;br&gt;
string for you. It also is very fast because it calls a &lt;br&gt;
native .dll directly. The data is placed in a structure of &lt;br&gt;
mixed type so you end up with:&lt;br&gt;
&lt;br&gt;
data.Symbol&lt;br&gt;
data.Exchange&lt;br&gt;
data.Date...&lt;br&gt;
&lt;br&gt;
..etc.&lt;br&gt;
&lt;br&gt;
It is not very elegant code since it was literally the &lt;br&gt;
first m-file I ever wrote but it has worked for years &lt;br&gt;
without a revision and is used in the financial, &lt;br&gt;
engineering and medical communities. Its been tested up to &lt;br&gt;
1.2 GB ascii file size (with the 3GB switch enabled on 32-&lt;br&gt;
bit stand-alone systems).&lt;br&gt;
&lt;br&gt;
hth,&lt;br&gt;
Scott</description>
    </item>
    <item>
      <pubDate>Sat, 15 Mar 2008 19:48:37 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421083</link>
      <author>Arthur G</author>
      <description>On 2008-03-15 12:08:03 -0400, &quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; said:&lt;br&gt;
&lt;br&gt;
&amp;gt; &quot;Pekka &quot; &amp;lt;pekka.nospam.kumpulainen@tut.please.fi&amp;gt; wrote in&lt;br&gt;
&amp;gt; message &amp;lt;frg668$im6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Hi,&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; I am trying to read a large .txt file with 5 columns&lt;br&gt;
&amp;gt; and&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; over 12000 rows of data.  I'm having trouble getting&lt;br&gt;
&amp;gt; the&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; (row, column) numbers right.  The code looks like this;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; loop = 0;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; for i = 1:2&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; line1 = fgets(fid);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; end&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; while feof(fid) == 0&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; loop = loop+1;&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; line1 = fgets(fid);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; end&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Can anyone help?&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; Thanks.&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; Really hard to help much without knowing the structure of&lt;br&gt;
&amp;gt;&amp;gt; your file. Hard coding the indexing is generally not a&lt;br&gt;
&amp;gt; good&lt;br&gt;
&amp;gt;&amp;gt; idea. That will fail if any of the lines has different&lt;br&gt;
&amp;gt;&amp;gt; length in any of the fields.&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; Take a look at&lt;br&gt;
&amp;gt;&amp;gt; doc textscan&lt;br&gt;
&amp;gt;&amp;gt; that should read the entire file wthout loops and hard&lt;br&gt;
&amp;gt;&amp;gt; coded indexing.&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; I thought about that after the post.  The file is too big&lt;br&gt;
&amp;gt; to show but it is a mix of text and numbers in a columnated&lt;br&gt;
&amp;gt; form.  The first column is text with various indenting, the&lt;br&gt;
&amp;gt; second column is text, and the last 3 columns are numbers.&lt;br&gt;
&amp;gt; I've seen the limitation of the hard coding but didn't know&lt;br&gt;
&amp;gt; of another way.  My goal is to have a code that will read&lt;br&gt;
&amp;gt; different text files of the same general format.  Thanks&lt;br&gt;
&amp;gt; for the replies.&lt;br&gt;
&lt;br&gt;
I'm not sure what you mean by &quot;various indenting&quot;, and that detail &lt;br&gt;
could potentially make things more complicated. But one approach I've &lt;br&gt;
used it to read a line at a time using fgetl, use textscan to parse &lt;br&gt;
each column into strings (specifying the &quot;Delimiter&quot; as whatever &lt;br&gt;
separates your columns), and then storing everything in a cell. &lt;br&gt;
Afterward, I then try to convert every element of the cell into a &lt;br&gt;
number (using sscanf seems fastest), and replace the string with a &lt;br&gt;
number if the conversion is successful. That seems to be my best &lt;br&gt;
compromise between speed and flexibility.&lt;br&gt;
&lt;br&gt;
--Arthur</description>
    </item>
    <item>
      <pubDate>Sun, 16 Mar 2008 00:45:05 -0400</pubDate>
      <title>Re: how to read text file row/column info</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165719#421110</link>
      <author>Bruce </author>
      <description>Arthur G &amp;lt;gorramfreak+news@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;47dc2815$0$289$b45e6eb0@senator-bedfellow.mit.edu&amp;gt;...&lt;br&gt;
&amp;gt; On 2008-03-15 12:08:03 -0400, &quot;Bruce Eddy&quot; &lt;br&gt;
&amp;lt;sailboats@cfl.rr.com&amp;gt; said:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Pekka &quot; &amp;lt;pekka.nospam.kumpulainen@tut.please.fi&amp;gt; wrote &lt;br&gt;
in&lt;br&gt;
&amp;gt; &amp;gt; message &amp;lt;frg668$im6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &quot;Bruce Eddy&quot; &amp;lt;sailboats@cfl.rr.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &amp;lt;frfjcc$it5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; Hi,&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; I am trying to read a large .txt file with 5 columns&lt;br&gt;
&amp;gt; &amp;gt; and&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; over 12000 rows of data.  I'm having trouble getting&lt;br&gt;
&amp;gt; &amp;gt; the&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; (row, column) numbers right.  The code looks like &lt;br&gt;
this;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; loop = 0;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; for i = 1:2&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; while feof(fid) == 0&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; loop = loop+1;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; line1 = fgets(fid);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; mass_prop(loop).name = line1(1, 1: 66);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; mass_prop(loop).matl = line1(1,67: 102);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; mass_prop(loop).volm = line1(1,103: 119);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; mass_prop(loop).dens = line1(1,120:133);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; mass_prop(loop).wght = line1(1,134:149);&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; Can anyone help?&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt; Thanks.&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Really hard to help much without knowing the structure &lt;br&gt;
of&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; your file. Hard coding the indexing is generally not a&lt;br&gt;
&amp;gt; &amp;gt; good&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; idea. That will fail if any of the lines has different&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; length in any of the fields.&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Take a look at&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; doc textscan&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; that should read the entire file wthout loops and hard&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; coded indexing.&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I thought about that after the post.  The file is too &lt;br&gt;
big&lt;br&gt;
&amp;gt; &amp;gt; to show but it is a mix of text and numbers in a &lt;br&gt;
columnated&lt;br&gt;
&amp;gt; &amp;gt; form.  The first column is text with various indenting, &lt;br&gt;
the&lt;br&gt;
&amp;gt; &amp;gt; second column is text, and the last 3 columns are &lt;br&gt;
numbers.&lt;br&gt;
&amp;gt; &amp;gt; I've seen the limitation of the hard coding but didn't &lt;br&gt;
know&lt;br&gt;
&amp;gt; &amp;gt; of another way.  My goal is to have a code that will &lt;br&gt;
read&lt;br&gt;
&amp;gt; &amp;gt; different text files of the same general format.  Thanks&lt;br&gt;
&amp;gt; &amp;gt; for the replies.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm not sure what you mean by &quot;various indenting&quot;, and &lt;br&gt;
that detail &lt;br&gt;
&amp;gt; could potentially make things more complicated. But one &lt;br&gt;
approach I've &lt;br&gt;
&amp;gt; used it to read a line at a time using fgetl, use &lt;br&gt;
textscan to parse &lt;br&gt;
&amp;gt; each column into strings (specifying the &quot;Delimiter&quot; as &lt;br&gt;
whatever &lt;br&gt;
&amp;gt; separates your columns), and then storing everything in a &lt;br&gt;
cell. &lt;br&gt;
&amp;gt; Afterward, I then try to convert every element of the &lt;br&gt;
cell into a &lt;br&gt;
&amp;gt; number (using sscanf seems fastest), and replace the &lt;br&gt;
string with a &lt;br&gt;
&amp;gt; number if the conversion is successful. That seems to be &lt;br&gt;
my best &lt;br&gt;
&amp;gt; compromise between speed and flexibility.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; --Arthur&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Here is a sample of the file I'm trying to read, maybe it &lt;br&gt;
will make more sense.  The info is seperated into columns &lt;br&gt;
with spaces between, no tabs or commas.  The first column &lt;br&gt;
is indented in groups (af's) and there are no spaces in the &lt;br&gt;
text.  The second column is text that has spaces in the &lt;br&gt;
phrase which complicates it some.  the other columns are &lt;br&gt;
all numbers.  Ultimately I need to read several files like &lt;br&gt;
this that get pretty large so I'm hoping to come up with a &lt;br&gt;
code that will fit all sizes.  After reading the file the &lt;br&gt;
goal is to process it to eliminate duplicates replacing &lt;br&gt;
them with a single line and a quantity instead.  Next I &lt;br&gt;
need to sum one of the columns for all rows containing .prt.&lt;br&gt;
Hopefully this is doable and not too ambitious.&lt;br&gt;
&lt;br&gt;
Thanks for the inputs.&lt;br&gt;
&lt;br&gt;
af_e_top_TIP_CURVE_WASHER.PRT                 NOT &lt;br&gt;
ASSIGNED                        0.003586       0.286000    &lt;br&gt;
0.001091     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;af_e_RC_TIP_DBLR_STRIP.PRT                    NOT &lt;br&gt;
ASSIGNED                        0.040392       0.101000    &lt;br&gt;
0.004080     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;af_e_top_TIP_CARD_CLVS.PRT                    NOT &lt;br&gt;
ASSIGNED                        0.014307       0.101000    &lt;br&gt;
0.001443     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;af_e_RFRST_RC_LWR_FTG_BALL_AS.ASM            NOT &lt;br&gt;
ASSIGNED                        4.231699       1.000000    &lt;br&gt;
0.438248     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;af_e_RFRST_RC_LWR_FTG_AS.ASM               NOT &lt;br&gt;
ASSIGNED                        4.203855       1.000000    &lt;br&gt;
0.430540     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MU_R_RFRST_RC_LWR_FTG.PRT                NOT &lt;br&gt;
ASSIGNED                        4.171692       0.101000    &lt;br&gt;
0.437095     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HDW_MS51830_203.PRT                       NOT &lt;br&gt;
ASSIGNED                        0.032163       0.286000    &lt;br&gt;
0.004314     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dt_s_RFRST_TETHER_BAL_af.ASM               NOT &lt;br&gt;
ASSIGNED                        0.026765       1.000000    &lt;br&gt;
0.007515     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dt_s_RFRST_TETHER_BALL_SK.PRT            NOT &lt;br&gt;
ASSIGNED                        0.000000       1.000000    &lt;br&gt;
0.000000     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dt_s_RFRST_TETHER_BALL.PRT               NOT &lt;br&gt;
ASSIGNED                        0.026288       0.280000    &lt;br&gt;
0.007361     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dt_SCD_RFRST_WIRE_ROP_SHT.PRT            NOT &lt;br&gt;
ASSIGNED                        0.000477       0.286000    &lt;br&gt;
0.000154     &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AF_S_RFRST_T_BALL_SPR_FER.PRT              NOT &lt;br&gt;
ASSIGNED                        0.000516       0.098000    &lt;br&gt;
0.000051     </description>
    </item>
  </channel>
</rss>

