how to read complicated text file
Mostra commenti meno recenti
Hello,
How to read the following "complicated" text file via textscan?
see attached file.dat:
name | multiplicity | pos | rot | excore
------------------------------------------------
a | 2 | 2 3 | 1 | 1
b | 1 | 1 2 3 | 6 | 1
c | 2 | 1 | 6 | 0
...
------------------------------------------------
The number of rows is uknown. The number of integers at column "pos" is variable.
Risposta accettata
Più risposte (2)
ES
il 19 Set 2013
use textscan with delimiter '|'
FileObj=fopen(FileName);
CellData=textscan(FileObj, ...
'%s %s %s %s %s %s %s %s %s', 'delimiter', '|');
1 Commento
Michal Kvasnicka
il 19 Set 2013
Azzi Abdelmalek
il 19 Set 2013
Modificato: Azzi Abdelmalek
il 19 Set 2013
fid = fopen('file.txt');
line1 = fgetl(fid);
res={line1};
while ischar(line1)
line1 = fgetl(fid);
res{end+1} =line1
end
fclose(fid);
res(end)=[]
1 Commento
Michal Kvasnicka
il 19 Set 2013
Modificato: Michal Kvasnicka
il 19 Set 2013
Categorie
Scopri di più su Text Files in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!