How to Read an Excel File dircetly form the Web in Julia Language?

In a former blog post (see here) I described how to read an Excel file into Julia. In this post I will focus on how to import an Excel file directly from the Web. This feature might be especially useful for recurring routines that rely on the most up-to-date data.

Generally, one can use various libraries to read Excel files, including XLSXReaderExcelReaders or Taro. This tutorial will focus on Taro as it created the fewest problems and provides – at least in my eyes – an easy to understand syntax. In order to download and read an Excel file into Julia it is sufficient to execute the following lines of code. This script downloads some sample data provided by this blog and reads it into Julia.

 
# in case you have not installed to Pkg yet
Pkg.add("Taro")

# load Taro - Pkg to read Excel Data
using Taro
Taro.init()

# get data
path = "https://economictheoryblog.files.wordpress.com/2016/08/data.xlsx"
df = Taro.readxl(download(path), "data", "A1:C357")


#
# The dataframe df contains the downloaded data
#

This routine will read the selected data fields, i.e. field A1 to field C357, of data into a dataframe in Julia. You can also directly consult the documentation of the Taro Package here.

Advertisements

One thought on “How to Read an Excel File dircetly form the Web in Julia Language?”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.