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 XLSXReader, ExcelReaders 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.
One thought on “How to Read an Excel File dircetly form the Web in Julia Language?”