Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use wget with Julia

I am interested in loading a file:

url: https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data

I am wondering if there is an option equivalent to !wget which can be used in python to load the file.

like image 311
tkxgoogle Avatar asked Mar 03 '23 10:03

tkxgoogle


2 Answers

The equivalent of Python's wget in Julia is download

To get the file to your disk just run:

download("https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data","./autofile.txt")

Do not use run for this because you take a risk that your code will not be portable.

like image 181
Przemyslaw Szufel Avatar answered Mar 05 '23 18:03

Przemyslaw Szufel


In order to download files, I tend to use the following helper function, which is fully implemented in Julia, does not rely on the availability of external tools, and is therefore entirely portable across systems (it does, however, depend on HTTP.jl):

import HTTP

function http_download(url, dest)
    HTTP.open(:GET, url) do http
        open(dest, "w") do file
            write(file, http)
        end
    end
end

http_download("http://www.julialang.org/", "/tmp/index.html")
like image 39
François Févotte Avatar answered Mar 05 '23 16:03

François Févotte