Importing multiple files with the same content and saving each uniquely

조회 수: 2 (최근 30일)
I have about 200 files that all have the same headers, I have been doing one file at a time, but found a mistake in my script and have to redue it all over again.
Is there a simple way for me to just run all of my .txt files at once, or simultaneously and save them uniquely, so that I can differentiate between each saved file?
my current script for importing: (I save each with the same name and rename them right now)
%%this will filter out the first row and create each column header as the variable name
fid = fopen('RD2_MB3_2700_EB.txt','r'); %<--- File to be imported
firstline = fgetl(fid);
firstline = regexprep(firstline,'-Angle Based','');
numvars = numel(strread(firstline,'%s'));
fgetl(fid); %<-- Skip the second line
data = textscan(fid,repmat('%f',1,numvars));
eval(['[' strrep(firstline,' ',',') '] = deal(data{:})']);

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 2월 15일

추가 답변 (2개)

Image Analyst
Image Analyst 2013년 2월 15일

Andrew
Andrew 2013년 2월 15일
Thanks!

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by