Data import to workspace from multiple .0 files(dot zero files)
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MaheKK
el 27 de En. de 2015
Comentada: MaheKK
el 28 de En. de 2015
Hi,
I am using following function to import data from a .0 file(dot zero file=text file) into Matlab workspace.
Select Text File Data Using Import Tool - http://de.mathworks.com/help/matlab/import_export/import-data-interactively.html
Now I wanted to import data from N number of .0 files, so i generated a function -importfile4.m manually from Import selection.
In a separate multiplefiles.m file I wrote the following code to repeat the same for N no. of files.
numFiles = 8; startRow = 2; endRow = inf; myData = cell(1,numFiles);
for fileNum = 1:numFiles filename = sprintf('%d.0',fileNum); Data{fileNum} = importfile4(filename,startRow,endRow); end
but i am getting the following error.
>> multiplefiles Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier.
Error in importfile4 (line 37) dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
Error in multiplefiles (line 15) Data{fileNum} = importfile4(filename,startRow,endRow);
Note : Files I am using looks like the following and extension is .0
file 1 name - {3BA6AFC6-DB3F-4833-AED2-C2F147172C0D}.0 file 2 name - {4D78FD28-28D4-40A6-9C1C-277969C600AA}.0
I use Windows operating system,Please help me where am I doing wrong?
Many thanks in Advance.
0 comentarios
Respuesta aceptada
Geoff Hayes
el 28 de En. de 2015
Mahesh - the error message is telling you that the fopen failed for your input file. So put a breakpoint at the line in the importfile4 function where the fileID variable is initialized (probably something like fileID = fopen(filename);. Run your code and when it pauses at this line, step to the next line. What is the value of fileID? If it is negative (or zero) then MATLAB has not been able to find the file. If that is the case, then ask yourself where is this file relative to importfile4? Are they both in the same directory? If not, then you will need to include the full path to the file and not just its name.
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.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!