Can MATLAB read a file inside a file?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Akana Juliet
 el 13 de Ag. de 2021
  
    
    
    
    
    Comentada: Cris LaPierre
    
      
 el 13 de Ag. de 2021
            Hi all. I have MATLAB reading in a text file successfully into a structure. But I would like for my text file to point to  csv file to read in.
So I read in the text file data and it is a list of parameters. but one of the parameters listed is another read-in file.
*Edit*
I am using a file that reads in and parses the data based on type. This is what it looks like:
function result = load_data( r )
            %LOAD_DATA recursively convert java objects
            if isa(r, 'char')
                result = char(r);
            elseif isa(r, 'double')
                result = double(r);
            elseif isa(r, 'logical')
                result = logical(r);
Is there a way I can say something like "elseif isa(r, 'csv, text, or yaml file, etc') ?
Thanks in advance!
0 comentarios
Respuesta aceptada
  Cris LaPierre
    
      
 el 13 de Ag. de 2021
        Yes, it is possible, but there is no function that will do this on its own. You will need to write your own code to parse the first file and then perform the desired operations with the data it has loaded. This could be a second read file operation using a file name obtained from the first file.
6 comentarios
  Cris LaPierre
    
      
 el 13 de Ag. de 2021
				You doen't read that string in as a file. You read it in as a string. Then you have some follow up code that then reads in the csv file using that name captured in the string.
[~,f,x] = fileparts('file.csv')
Más respuestas (0)
Ver también
Categorías
				Más información sobre Cell Arrays 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!

