unzip a list of urls from txt file

2 visualizaciones (últimos 30 días)
Reema Alhassan
Reema Alhassan el 23 de Mayo de 2018
Comentada: Reema Alhassan el 30 de Mayo de 2018
this is my code I read the urls from a txt file but now I need to unzip them all
when I unzip them I always get the same error
could anyone please show me the code of doing that thanks.
file = input('Enter file name: ','s'); % prompt the user to enter file name
str= fileread(file);
% a pattern for reading urls
C = regexpi(str, ...
['((http|https|ftp|file)://|www\.|ftp\.)',...
'[-A-Z0-9+&@#/%=~_|$?!:,.]*[A-Z0-9+&@#/%=~_|$]'], 'match');
C{:};
for k = 1:numel(C)
element=C(k);
% disp(C(k));
unzip(element,'MATLAB');
end
the error is: Error using exist The first input to exist must be a string scalar or character vector.
Error in parseUnArchiveInputs (line 74) if exist(archiveFilename,'dir') && ~isempty(dir(archiveFilename))
Error in unzip (line 57) [zipFilename, outputDir, url, urlFilename] = parseUnArchiveInputs( ...
Error in project2 (line 17) unzip(element,'MATLAB');

Respuesta aceptada

Jan
Jan el 23 de Mayo de 2018
Editada: Jan el 23 de Mayo de 2018
The line
C{:};
performs nothing. Delete it.
unzip needs a file name as char vector as first input, but element=C(k) creates a scalar cell string. Use this instead:
element = C{k}; % Curly braces
By the way, I'm not sure if "unzipping an URL" is a meaningful task. It depends on the contents of the data.
  3 comentarios
Jan
Jan el 30 de Mayo de 2018
@Reema Alhassan: Please post comments in the section for comments. Thanks.
Do you provide the URL as input to unzip or did you download the file and call unzip afterwards? Matlab's unzip is a java implementation. I assume calling e.g. 7zip will be much faster. And I'm not sure if unzip works at all for tar-gnuzip files. Did you test this?
Reema Alhassan
Reema Alhassan el 30 de Mayo de 2018
I have tried gunzip with untar together and and it is working thanks a lot ..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by