How to find the index of the line to find the occurrence of perticular character
Afficher commentaires plus anciens
Hi
I have multiple text files, and am reading. But I want to find the number lines in a text files(s), and also find the occurrence of dotted line(s)'------'. I use the following code, but I am unable to find the index of the dotted lines(s).My code giving 'Zero'. In fact the first dotted line occurs at line number 23 (row number), and the second dotted lines is occurring at line number 41 (row number). Please help me how can I do this.
clc;clear all;
clc
tic
FileList=dir('D:\Mekala_Backupdata\Matlab2010\Filesfolder\Try2/');
j=1;
for i=3:1:(size(FileList)) %%read all files from folder of specified dir
FileName{j}=FileList(i).name;
j=j+1;
end
% fid = fopen('yourFile.ext');
for j=1:size(FileName,2)
fid=fopen(['D:\Mekala_Backupdata\Matlab2010\Filesfolder\Try2/',FileName{j}],'r'); %%opening each files and read each line
allText = textscan(fid,'%s','delimiter','\n');
numberOfLines = length(allText{1});
fclose(fid)
end
[~,indx]=ismember('----+',FileName,'rows');
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!