tkxgoogle
tkxgoogle

Reputation: 447

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.

Upvotes: 4

Views: 1082

Answers (3)

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")

Upvotes: 3

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42244

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.

Upvotes: 3

Igor Rivin
Igor Rivin

Reputation: 4864

If you want to run any shell command, you use run as described here. If you want to read the file into Julia, then DelimitedFiles is your friend.

Upvotes: 2

Related Questions