unzip a list of urls from txt file

3 visualizzazioni (ultimi 30 giorni)
Reema Alhassan
Reema Alhassan il 23 Mag 2018
Commentato: Reema Alhassan il 30 Mag 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');

Risposta accettata

Jan
Jan il 23 Mag 2018
Modificato: Jan il 23 Mag 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 Commenti
Jan
Jan il 30 Mag 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 il 30 Mag 2018
I have tried gunzip with untar together and and it is working thanks a lot ..

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB Report Generator in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by