Import .file values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a .file I need to import the data into matlab, but i have trouble handling the format.
Any help?
0 commentaires
Réponse acceptée
Voss
le 5 Avr 2024
unzip file.zip
ls *.file
str = fileread('file.file')
C = regexp(str,'([^\r\n]+)\d{2}{''y'':(.+?), ''x'':(.+?), ''z'':(.+?)}','tokens');
C = vertcat(C{:})
t = strtrim(C(:,1))
yxz = str2double(C(:,2:end))
5 commentaires
Voss
le 7 Avr 2024
The code in my answer uses fileread, so I guess you are trying to run the code in my comment, which is for combining multiple files into one. Since you don't have readlines, try this instead:
unzip file.zip
ls *.file
directory = '.'; % directory where your files are
output_file = 'all_files.file'; % output file to write, containing contents of all files
files = dir(fullfile(directory,'*.file'));
files = fullfile({files.folder},{files.name});
N = numel(files);
C = cell(N,1);
for ii = 1:N
C{ii} = regexprep(fileread(files{ii}),'\r?\n$','');
end
fid = fopen(output_file,'w');
fprintf(fid,'%s\n',strjoin(C,newline()));
fclose(fid);
% check the result for these two files
type(output_file)
Voss
le 7 Avr 2024
C = regexp(str,'([^\r\n]+)\d{2}{''y'':(.+?), ''x'':(.+?), ''z'':(.+?)} {''a'':(.+?), ''b'':(.+?), ''c'':(.+?)}','tokens');
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!