importdata headerline concatenate files
2 views (last 30 days)
Show older comments
Hello, this is a continuation to my question: concatenate and replace comma by dot. Well, I have a series of 300 files with names respectively from data-1.dat to data300.dat. Each file consist of 6 columns and 25 rows and a headerline (files contain scalars with comma instead of dot, ex: 3,21223232) I want to concatenate all files into one matrix and I'm using the code below:
% code
numfiles = 300;
concat= cell(1, numfiles);
for i=1:300;
i
filename = sprintf(data-%d.dat, i);
concat{i} = importdata(filename, '\t');
end
newFile = fullfile(tempdir, 'JoinedFile.dat');
FID = fopen(newFile, 'w');
if FID == -1, error('Cannot open file for writing'); end
fprintf(FID, '%s', concat{:});
fclose(FID);
Then I import the file "JoinedFile.dat" but I'm struggling with the headerline, when I use the code below:
all_data= importdata('JoinedFile.dat');
It imports data in a string with text, colheader and data but only the first set of 25 rows and 6 columns (it means that it doesn't read the next headerline) and leave 299 sets.
Best regards,
1 Comment
Jan
on 20 Dec 2012
I've answered this in your former question http://www.mathworks.com/matlabcentral/answers/56828-concatenate-and-replace-comma-by-dot already.
Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!