필터 지우기
필터 지우기

Unzipping a uint8 array

조회 수: 5 (최근 30일)
Marco Rossi
Marco Rossi 2018년 9월 24일
댓글: Sean de Wolski 2019년 12월 2일
Goodmorning sirs,
I am accessing with 'webread' to a zip file located on a webserver. This zip file contains few tens of xml files. The webread function returns an array of uint8 (ascii code of the zip file I guess). Is there any method to unzip it directly on the workspace?
Thanks in advance for the support.

답변 (3개)

ANKUR KUMAR
ANKUR KUMAR 2018년 9월 24일
Use unzip(zipfilename) unzip(zipfilename,directory)
  댓글 수: 1
Stephen23
Stephen23 2018년 9월 24일
Marco Rossi's "Answer" moved here:
well, unzip(webread('www....')) does not seem to work, since webread returns an array of uint8. Is there a way to unzip a uint8 array (corresponding to the ascii of a zip file) without creating the physical zip file?

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2018년 9월 24일
There are Java based methods to unzip from memory streams. MATLAB's unzip uses some of the relevant methods and you can also see them in how readtable works on xlsx files.
However, it does not make complete sense to unzip an XML into the workspace. Are you looking for it to be converted to a character vector or for it to be parsed into data?
  댓글 수: 1
Stephen23
Stephen23 2018년 9월 24일
Marco Rossi's "Answer" moved here:
I am mostly interested in getting the xml string for the moment (maybe a single string merging the content of all the files). I am trying to look at the java libraries used by Matlab to unzip, but it seems to be not so straightforward.

댓글을 달려면 로그인하십시오.


Sean de Wolski
Sean de Wolski 2018년 9월 24일
Use websave instead:
tempzipname = [tempname '.zip']
websave(tempzipname, url);
deleter = onCleanup(@()delete(tempzipname));
unzip(tempzipname)
You can also use tempname to generate a folder to unzip to, and then xmlread or fileread to read it in.
  댓글 수: 2
Marc Youcef
Marc Youcef 2019년 11월 30일
I think this was not what the author was asking in the first time. He (and me as well) - We are looking for a way to unzip to ram without using file system for decompression.
I found some info here https://undocumentedmatlab.com/blog/savezip-utility but could not get an implementation out of it. If anyone has an idea please share.
Would be great to have an evolved version of unzip function which takes a byte array as input and byte array output.
Sean de Wolski
Sean de Wolski 2019년 12월 2일
Marc, that seems like a fair enhancement request. I put an enhancement in to development for it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by