search in large cell file
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Frank Oosterveld
 el 27 de Oct. de 2020
  
    
    
    
    
    Respondida: Jan
      
      
 el 27 de Oct. de 2020
            Hi all,
I'm looking for a function such that I can acces the following text in my SSD file (attached)
THE FOLLOWING TABLE IS PRINTED FOR NODES BELONGING TO NODE SET ASSEMBLY_DISPLACEMENT_NODE,
I open my SSD file according to: 
clear all, clc, format longG
Counter = 1;
FID = fopen('SSD_anal - Copy.dat', 'rt'); 
tline = fgetl(FID);
File_Data{Counter} = tline;
while ischar(tline)
    Counter = Counter+1;
    tline = fgetl(FID);
    File_Data{Counter} = tline;
end
fclose(FID);
File_Data = File_Data';
Which brings me a cell 76540x1 cell, I tried to find the indices by:
Index = find(contains(File_Data,'THE FOLLOWING TABLE IS PRINTED FOR NODES BELONGING TO NODE SET ASSEMBLY_DISPLACEMENT_NODE'));
and 
IndexC = strfind(File_Data,'THE FOLLOWING TABLE IS PRINTED FOR NODES BELONGING TO NODE SET ASSEMBLY_DISPLACEMENT_NODE');
but nothing works, as it states that: 
Error using strfind
Cell must be a cell array of character vectors.
Any clues how I could find the indices where the file states the statement above?
greetings and thanks for your help and attention already!
0 comentarios
Respuesta aceptada
  Jan
      
      
 el 27 de Oct. de 2020
        In the loop all lines are stored in the cell an the loops stops, if the last one was not a CHAR. This means, that the last element of the cell is not a CHAR, exactly as the error message tells you.
Either remove the last element:
File_Data(end) = [];
or use a more compact method to import the text:
S         = fileread('SSD_anal - Copy.dat');
File_Data = strsplit(S, char(10));
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Large Files and Big Data en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

