Read txt file with no header
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all, I have attached one of the txt I need to extract only the numeric data from, skipping thr headers. it works for that file but I want to extens the code to files with a different (unknown) number of columns. Can anyone help me to modify it?
The piece of code I used is:
fid=fopen('text.txt');
data=textscan(fid,'%f %f %f %f %f %f %f %f %f %f','HeaderLines','4');
data=cell2mat(data);
fclose(fid);
Thanks
0 Commenti
Risposta accettata
Les Beckham
il 22 Apr 2022
Modificato: Les Beckham
il 22 Apr 2022
This should work for any number of columns and it automatically detects the number of header rows and the variable names.
t = readtable('text.txt')
data = table2array(t); % convert to a plain numeric array
whos data
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!