Importing .txt files from directory and save them as .mat data files
Mostrar comentarios más antiguos
I can successfully import all the files and save them as .mat, but I can't get it to the right format. I want it to be saved as a table or a format that i could access quickly. I am getting a Data that has variable Data that has two variables in it Data and TextCells.
Xpos = 'North';
Xname = 'Tatat';
Xtime = '20131213_1500-20140205_1137';
X_beg = datenum(Xtime(1:13), 'yyyymmdd_HHMM');
A_Data_loc = 'Data15';
a_file_list = dir(fullfile([A_Data_loc filesep Xpos], '*.txt'));
for i=1:max(size(a_file_list))%max(size(a_file_list))
a_data_name = a_file_list(i).name;
a_data_mon = datenum(a_data_name(5:10), 'mmmyy');
a_file_path = [A_Data_loc filesep Xpos filesep a_file_list(i).name];
% importdata(a_file_path)
%delimiterIn=';';
%headerlinesIn=1;
Data=importdata(a_file_path);
%Change file name
a_data_name_new=a_data_name(1:9);
%rename the file
save(a_data_name_new,'Data');
end
The text file looks like that. I tried to do with readtable, but this created also 1 variable, but I want all the headers to be variables. Can i do it with textscan? I tried, but failed.
DAY;TIME;LAT;LON;Vs;DISTKM
01-04-2013;19:09:11;65.79196167;19.49089;19.7912277594236
Thank you for any suggestions!
Gert
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Import and Analysis en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!