读取zip文件中的文本文件,而无需在matlab中解压缩

时间:2019-03-18 17:27:12

标签: matlab zip fopen

我想在不使用Matlab解压缩的情况下读取zip文件中的文本文件

Read the data of CSV file inside Zip File without extracting the contents in Matlab

上面的建议正在工作,我得到了文件的单元格列表。

zipFilename = 'C:\ZippedData.zip';
zipJavaFile  = java.io.File(zipFilename);
% Create a Java ZipFile

 zipFile = org.apache.tools.zip.ZipFile(zipJavaFile);
% Extract the entries from the ZipFile.

 entries = zipFile.getEntries;
 cnt = 1;
% Get Zip File Paths

 while entries.hasMoreElements
   tempObj = entries.nextElement;
   file{cnt,1} = tempObj.getName.toCharArray';
   cnt = cnt+ 1;
 end
% Extract File Name

 ind = regexp(file,'textfile.*');
 ind = find(~cellfun(@isempty,ind));  % Find Non Empty Cell Index
 file = file(ind);
% Create Absolute Path so that Windows consider as Directory

file = cellfun(@(x) fullfile('.',x),file,'UniformOutput',false);

\ file1,。\ file2,...,。\ filen,但是他们如何在fopen中使用它并说textscan?类似于fileID = fopen([zipFilename filesep file {1}]); ?。

0 个答案:

没有答案