How to scan text file?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mira le
le 8 Jan 2020
Réponse apportée : Bhaskar R
le 8 Jan 2020
Hello every one
I have a text file contains:
1,24,85,90
23,36
34,36,39,56,85,86,90
34,59,67,85,86
39,85,93
I want to scan it
How can I do that , please help me!
0 commentaires
Réponse acceptée
Walter Roberson
le 8 Jan 2020
filename = 'AppropriateName.txt';
S = fileread(filename);
L = regexp(S, '\r?\n', 'split');
data = cellfun(@(s) str2double(regexp(s, ',', 'split')), L, 'uniform', 0);
The result will be a cell array with one entry per line, with each entry being the numeric data from the corresponding line.
0 commentaires
Plus de réponses (1)
Bhaskar R
le 8 Jan 2020
data = readtable('yourfile.txt', 'Delimiter', ',',...
'HeaderLines', 0, 'ReadVariableNames',false, 'Format', '%d');
0 commentaires
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!