how to read complicated text file
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (2)
ES
am 19 Sep. 2013
use textscan with delimiter '|'
FileObj=fopen(FileName);
CellData=textscan(FileObj, ...
'%s %s %s %s %s %s %s %s %s', 'delimiter', '|');
1 Kommentar
Michal Kvasnicka
am 19 Sep. 2013
Azzi Abdelmalek
am 19 Sep. 2013
Bearbeitet: Azzi Abdelmalek
am 19 Sep. 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 Kommentar
Michal Kvasnicka
am 19 Sep. 2013
Bearbeitet: Michal Kvasnicka
am 19 Sep. 2013
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!