<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668</link>
    <title>MATLAB Central Newsreader - how to read/import multiple files which have headings</title>
    <description>Feed for thread: how to read/import multiple files which have headings</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, 09 Jun 2008 13:36:01 -0400</pubDate>
      <title>how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#436485</link>
      <author>julia </author>
      <description>Hi, &lt;br&gt;
I am a beginner when it comes to Matlab and am trying now &lt;br&gt;
for some time to get my data in the most efficient way into &lt;br&gt;
matlab for further processing. Its rather a lot of files &lt;br&gt;
(Test1, Test2 ....) which have some headers and are &lt;br&gt;
delimited with ; in ASCI format. I was hoping that there is &lt;br&gt;
some automation possible: &lt;br&gt;
&lt;br&gt;
My input gives me an error with the textread and i dont &lt;br&gt;
really know how to fix it.  Any help appreciated !&lt;br&gt;
-----------&lt;br&gt;
clear all; close all; &lt;br&gt;
for k = 1:50&lt;br&gt;
&amp;nbsp;&amp;nbsp;textfilename = ['Test' num2str(k) '.ASC'];&lt;br&gt;
&amp;nbsp;&amp;nbsp;fid = fopen(textfilename, 'rt');&lt;br&gt;
&amp;nbsp;&amp;nbsp;data = textread(fid,'','delimiter',';','headerlines',7);&lt;br&gt;
&amp;nbsp;&amp;nbsp;savefile=['Test' num2str(k) '.mat'];  &lt;br&gt;
&amp;nbsp;&amp;nbsp;nrows=size(data,1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;ncolumns=size(data,2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;data=data(:,1:ncolumns-1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;lengte = length(data);&lt;br&gt;
&amp;nbsp;&amp;nbsp;Time=data(1:lengte,1);&lt;br&gt;
% then come lots of variable &amp; calc etc which are fine &lt;br&gt;
which I omitted here...&lt;br&gt;
&amp;nbsp;&amp;nbsp;save(savefile,'Time');&lt;br&gt;
&amp;nbsp;&amp;nbsp;fclose(fid);&lt;br&gt;
end&lt;br&gt;
--------</description>
    </item>
    <item>
      <pubDate>Mon, 09 Jun 2008 13:49:02 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#436492</link>
      <author>French Caro</author>
      <description>&quot;julia &quot; &amp;lt;julia.krohn@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g2jbk1$ht2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, &lt;br&gt;
&amp;gt; I am a beginner when it comes to Matlab and am trying now &lt;br&gt;
&amp;gt; for some time to get my data in the most efficient way into &lt;br&gt;
&amp;gt; matlab for further processing. Its rather a lot of files &lt;br&gt;
&amp;gt; (Test1, Test2 ....) which have some headers and are &lt;br&gt;
&amp;gt; delimited with ; in ASCI format. I was hoping that there is &lt;br&gt;
&amp;gt; some automation possible: &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My input gives me an error with the textread and i dont &lt;br&gt;
&amp;gt; really know how to fix it.  Any help appreciated !&lt;br&gt;
&amp;gt; -----------&lt;br&gt;
&amp;gt; clear all; close all; &lt;br&gt;
&amp;gt; for k = 1:50&lt;br&gt;
&amp;gt;   textfilename = ['Test' num2str(k) '.ASC'];&lt;br&gt;
&amp;gt;   fid = fopen(textfilename, 'rt');&lt;br&gt;
&amp;gt;   data = textread(fid,'','delimiter',';','headerlines',7);&lt;br&gt;
&amp;gt;   savefile=['Test' num2str(k) '.mat'];  &lt;br&gt;
&amp;gt;   nrows=size(data,1);&lt;br&gt;
&amp;gt;   ncolumns=size(data,2);&lt;br&gt;
&amp;gt;   data=data(:,1:ncolumns-1);&lt;br&gt;
&amp;gt;   lengte = length(data);&lt;br&gt;
&amp;gt;   Time=data(1:lengte,1);&lt;br&gt;
&amp;gt; % then come lots of variable &amp; calc etc which are fine &lt;br&gt;
&amp;gt; which I omitted here...&lt;br&gt;
&amp;gt;   save(savefile,'Time');&lt;br&gt;
&amp;gt;   fclose(fid);&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; --------&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
Hi,&lt;br&gt;
I think that you should use texscan in place of textread.&lt;br&gt;
Both do the same thing but don't have the same inputs :&lt;br&gt;
textread take as first parameter the name of the file not&lt;br&gt;
the fid while textscan take the fid (file identifier) as&lt;br&gt;
first input.&lt;br&gt;
&lt;br&gt;
Caroline</description>
    </item>
    <item>
      <pubDate>Mon, 09 Jun 2008 19:24:01 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#436546</link>
      <author>Andres </author>
      <description>&quot;julia &quot; &amp;lt;julia.krohn@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g2jbk1$ht2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, &lt;br&gt;
&amp;gt; I am a beginner when it comes to Matlab and am trying now &lt;br&gt;
&amp;gt; for some time to get my data in the most efficient way into &lt;br&gt;
&amp;gt; matlab for further processing. Its rather a lot of files &lt;br&gt;
&amp;gt; (Test1, Test2 ....) which have some headers and are &lt;br&gt;
&amp;gt; delimited with ; in ASCI format. I was hoping that there is &lt;br&gt;
&amp;gt; some automation possible: &lt;br&gt;
[...]&lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
you may also give txt2mat from the file exchange a try.&lt;br&gt;
According to your file format description, simply write&lt;br&gt;
&lt;br&gt;
A = txt2mat;&lt;br&gt;
&lt;br&gt;
to browse manually, or&lt;br&gt;
&lt;br&gt;
A = txt2mat('c:\fileOrFolder');&lt;br&gt;
&lt;br&gt;
which is probably a bit more convenient than using textscan&lt;br&gt;
&amp;nbsp;(and similarly efficient).&lt;br&gt;
&lt;br&gt;
Hth, regards,&lt;br&gt;
Andres</description>
    </item>
    <item>
      <pubDate>Thu, 12 Jun 2008 15:04:02 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#437157</link>
      <author>julia </author>
      <description>&lt;br&gt;
Great, in principle it works with textscan, except that &lt;br&gt;
matlab seems to crash at file no 45 and i have plenty &lt;br&gt;
more... any idea how to get around this ? The file is not &lt;br&gt;
corrupted or anything as it is processed if I only then go &lt;br&gt;
from 45 to the next 89 its ok again ? &lt;br&gt;
&lt;br&gt;
Any help appreciated&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;French Caro &quot; &amp;lt;caro95470@nospam.free.fr&amp;gt; wrote in message &lt;br&gt;
&amp;lt;g2jcce$qve$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;julia &quot; &amp;lt;julia.krohn@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g2jbk1$ht2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi, &lt;br&gt;
&amp;gt; &amp;gt; I am a beginner when it comes to Matlab and am trying &lt;br&gt;
now &lt;br&gt;
&amp;gt; &amp;gt; for some time to get my data in the most efficient way &lt;br&gt;
into &lt;br&gt;
&amp;gt; &amp;gt; matlab for further processing. Its rather a lot of &lt;br&gt;
files &lt;br&gt;
&amp;gt; &amp;gt; (Test1, Test2 ....) which have some headers and are &lt;br&gt;
&amp;gt; &amp;gt; delimited with ; in ASCI format. I was hoping that &lt;br&gt;
there is &lt;br&gt;
&amp;gt; &amp;gt; some automation possible: &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; My input gives me an error with the textread and i dont &lt;br&gt;
&amp;gt; &amp;gt; really know how to fix it.  Any help appreciated !&lt;br&gt;
&amp;gt; &amp;gt; -----------&lt;br&gt;
&amp;gt; &amp;gt; clear all; close all; &lt;br&gt;
&amp;gt; &amp;gt; for k = 1:50&lt;br&gt;
&amp;gt; &amp;gt;   textfilename = ['Test' num2str(k) '.ASC'];&lt;br&gt;
&amp;gt; &amp;gt;   fid = fopen(textfilename, 'rt');&lt;br&gt;
&amp;gt; &amp;gt;   data = textread&lt;br&gt;
(fid,'','delimiter',';','headerlines',7);&lt;br&gt;
&amp;gt; &amp;gt;   savefile=['Test' num2str(k) '.mat'];  &lt;br&gt;
&amp;gt; &amp;gt;   nrows=size(data,1);&lt;br&gt;
&amp;gt; &amp;gt;   ncolumns=size(data,2);&lt;br&gt;
&amp;gt; &amp;gt;   data=data(:,1:ncolumns-1);&lt;br&gt;
&amp;gt; &amp;gt;   lengte = length(data);&lt;br&gt;
&amp;gt; &amp;gt;   Time=data(1:lengte,1);&lt;br&gt;
&amp;gt; &amp;gt; % then come lots of variable &amp; calc etc which are fine &lt;br&gt;
&amp;gt; &amp;gt; which I omitted here...&lt;br&gt;
&amp;gt; &amp;gt;   save(savefile,'Time');&lt;br&gt;
&amp;gt; &amp;gt;   fclose(fid);&lt;br&gt;
&amp;gt; &amp;gt; end&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; &lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; I think that you should use texscan in place of textread.&lt;br&gt;
&amp;gt; Both do the same thing but don't have the same inputs :&lt;br&gt;
&amp;gt; textread take as first parameter the name of the file not&lt;br&gt;
&amp;gt; the fid while textscan take the fid (file identifier) as&lt;br&gt;
&amp;gt; first input.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Caroline</description>
    </item>
    <item>
      <pubDate>Thu, 12 Jun 2008 15:24:02 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#437160</link>
      <author>French Caro</author>
      <description>&quot;julia &quot; &amp;lt;julia.krohn@gmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g2rdt2$gue$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Great, in principle it works with textscan, except that &lt;br&gt;
&amp;gt; matlab seems to crash at file no 45 and i have plenty &lt;br&gt;
&amp;gt; more... any idea how to get around this ? The file is not &lt;br&gt;
&amp;gt; corrupted or anything as it is processed if I only then go &lt;br&gt;
&amp;gt; from 45 to the next 89 its ok again ? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any help appreciated&lt;br&gt;
&amp;gt; &lt;br&gt;
Hi,&lt;br&gt;
&lt;br&gt;
When you say that MATLAB crashes  : what does it really do ?&lt;br&gt;
Do you have any error message or crash dump ? or just nothing ?&lt;br&gt;
And do you reach to read this file no 45 ?&lt;br&gt;
&lt;br&gt;
Have you given Andres' proposal a try ?&lt;br&gt;
&lt;br&gt;
Caroline</description>
    </item>
    <item>
      <pubDate>Thu, 12 Jun 2008 19:29:03 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#437195</link>
      <author>William </author>
      <description>Another possibility, albeit a round about way, would be to &lt;br&gt;
have excel convert those files then do xlsread to bring in &lt;br&gt;
the Raw data in a cell towhich you can alter it as you see &lt;br&gt;
fit.  You could further automate this process if your &lt;br&gt;
filenames follow the same format as you've posted (Test1, &lt;br&gt;
Test2, etc) by using strcat and sprintf to run through all &lt;br&gt;
the filenames (so long as the route directery stays the &lt;br&gt;
same).  Just some thought.</description>
    </item>
    <item>
      <pubDate>Thu, 12 Jun 2008 19:52:37 -0400</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#437196</link>
      <author>Marcus M. Edvall</author>
      <description>Using xlsread might be very slow for you. Might want to run some tests&lt;br&gt;
on this first before converting your code.&lt;br&gt;
&lt;br&gt;
Best wishes, Marcus&lt;br&gt;
Tomlab Optimization Inc.&lt;br&gt;
&lt;a href=&quot;http://tomdyn.com/&quot;&gt;http://tomdyn.com/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 12 Feb 2009 11:14:01 -0500</pubDate>
      <title>Re: how to read/import multiple files which have headings</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/170668#627860</link>
      <author>S?rgio Magalh?es</author>
      <description>And what about if I had completely different file names and want to read all files in order to perform some simulations. How could I do it? The files have the extension *.odf and it can be opened as text using &quot;Open as Text&quot; in the current directory tab.&lt;br&gt;
Could anyone help me? I tried quite a few ways and with (for instance) dlmread I only can read one file and It is what I don't want.&lt;br&gt;
&lt;br&gt;
My best regards,&lt;br&gt;
&lt;br&gt;
S?rgio</description>
    </item>
  </channel>
</rss>

