Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

eval - data file that includes headers

Status
Not open for further replies.

dimikay1

Civil/Environmental
Mar 30, 2013
4
All,

I try to create an array with some data files and the code I use is the next one:

files=dir('F:\Strain Data\January\*.dat');
d={};
for i=1:length(files)
eval(['d{' int2str(i) '}=load(files(' int2str(i) ').name);']);
end

The code seems to work. However, my data files have headers! In that case the function "load" does not apply!!!

Any help?
 
Replies continue below

Recommended for you

use the uiimport command to analyse one file and tick the box marked generate m code. Then look at that to see how it has analysed your file.

I think this is the last post in which I do your assignment for you.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
I have already solved the problem. You cannot use uimport to import so many data files. This is not the solution. The solution is much much more complex than this. If you use uimport you need to import manually 20,000 files. You need a year for that.

But thank you for your time. However, if that's how feel please do not answer any of my next questions. I hope I didn't force you to do so far. But really thank you especially for the first time you answered my question. It gave me a really good idea about which concept to follow in the beginning.
 
Greg's suggestion is perfectly fine and the same one I would have given. Greg also helped get you to this point only a day earlier:


Before you burn all your bridges on this forum, please contribute to the spirit of helping others by posting your solution.
 
Yeesh... what's the deal with that guy? This seems like one of those situations where you don't look a gift horse in the mouth.

In case anyone stumbles across this thread looking for an answer, one solution might be to use the dlmread command, which allows you to skip header rows.

Code:
files=dir('F:\Strain Data\January\*.dat');
for n=1:length(files)
  data{n}=dlmread('files(n).name','\t',1);    %For a tab-delimited file. Skips first row.
end

This is not as complicated as the OP suggested.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor