Contents Previous Next Subchapters

Reading Data from the Internet
Syntax
urlget(
URLoutput file)
urlget(
URLoutput file, "binary")
See Also: h5read , read

Description
Reads a file from the address specified by the given Internet URL. The argument URL is a character row vector that specifies the valid URL of an ASCII file. The argument output file is a character row vector specifying the name of a file on your local system for storing the retrieved data. If present, the third argument must be "binary" and instructs the function to transfer the file at URL in binary-mode. That is no carriage return or line feed translations are performed.

Transferring ASCII Data
The two-argument form of urlget transfers the requested data in ASCII. That is any necessary carriage return and line feed transforms that are necessary for the given system are performed before storing the data on your system. This provides an efficient method of loading HTML, XML, or raw text data from Internet resources.

Examples
If you enter
     urlget("http://www.omatrix.com/urlget.csv", "C:\temp\tst.csv")
O-Matrix will download the file urlget.csv from the home directory on omatrix.com and save it on your local system. You can verify that this download succeeded by entering
     M = read("C:\temp\tst.csv", "int", 100, 100)
     contour(M)
which will produce the following contour plot

The urlget function can also be used to access server-side CGI resources. If you enter

clear
const tickers = {"hcow", "unfi","ebay"}
NTickers = rowdim(tickers)

uriStart = "http://table.finance.yahoo.com/table.csv?a=0&b=1&c=2002&d=11&e=31&f=2002&s="
uriEnd ="&y=0&g=w&ignore=.csv"
for i = 1 to NTickers begin
     sym = tickers.row(i)
     URL = [uriStart, sym, uriEnd]
     oFile = [sym, ".csv"]
     urlget(URL, ["c:\temp\", oFile]);
end  

O-Matrix will download weekly stock data for the symbols HCOW, UNFI, and EBAY from the Yahoo stock chart server.

Transferring Binary Data
The three-argument form of urlget transfers the requested data in binary mode. This function provides highly-optimized binary transfer of data from Internet resources to your local system.

Example
If you enter
     urlget("http://www.omatrix.com/downloads/LibSetup.zip", "C:\temp\Lib.zip", "binary")

O-Matrix will download the file LibSetup.zip from omatrix.com and save it on your local system.