I would like to read a specific string from the row which has been delimited.say for eg. i want the value 42724.6268698495. How do i do it. Its in a text file
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nazeer Akram Athaullah
am 3 Feb. 2017
Beantwortet: Walter Roberson
am 6 Feb. 2017
I would like to read a specific string from the row which has been delimited.say for eg. i want the value 42724.6268698495. How do i do it. Its in a text file
The file has data as below
#Started 20.12.2016 15:02:41 42724.6268698495
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 6 Feb. 2017
fid = fopen('YourFile.txt', 'rt');
data_cell = textscan(fid, '%*s%*s%*s%f', 'Delimiter', '\t');
fclose(fid)
data = data_cell{1};
0 Kommentare
Weitere Antworten (1)
Carl
am 6 Feb. 2017
You can use the "readtable" function to import your data. See the documentation below:
You can use something like the following command:
>> T = readtable('data.txt','Delimiter',' ','ReadVariableNames',false);
In the command above, I'm assuming that, 1. Your data is in a file named data.txt 2. Your data is delimited by a space 3. Your data file does not include headers
After you read the data into a table, you can access each element as necessary. If you only need the last column, you can do something like the following:
>> T = T(:, end);
1 Kommentar
Walter Roberson
am 6 Feb. 2017
The posted line turns out to be delimited by tabs, at least as posted. For that you would use 'Delimiter', '\t'
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!