0

I would like to read text files inside a zip file without unzipping using Matlab

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

The suggested above is working and I get list of cells for file.

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 , but them how do I use that in fopen and say textscan? something like fileID = fopen([zipFilename filesep file{1}]); ?.

N_s
  • 1
  • 1
  • Add a `Code` you so far have. Also an error message would be useful. "don't seem to work" is really not precise at all. – Karls Mar 18 '19 at 17:29
  • Welcome to StackOverflow! Please add more information about what you have tried so far, and any error/output that you get. Then it'll be easier to help you. – Miyuru Sagarage Mar 18 '19 at 17:59

0 Answers0