Import Data from the Hub

Download the data from the here.

For Scala you can use following singleton object Fetcher. It uses components from Java Platform SE and from Scala Standard Library.

The same problem as in Python example occurs here, header User-Agent needs to be present, see similar issue in Java.

// file: covid19datahub.scala

object COVID19Datahub {
  // method to fetch data
  def fetch(): (List[Array[String]],Array[String]) = {
    // download
    val url  = new"")
    val conn = url.openConnection
    // parse
    val text  =
    val lines = => line.split(",").map(_.trim)).toList
    // split header and data
    val header = lines.head
    val data   = lines.slice(1,lines.size)
    // return

The object can be used in following way

// file: main.scala

import covid19datahub.COVID19Datahub

object MainObject {
  def main(args: Array[String]): Unit = {
    val (data,header) = COVID19Datahub.fetch
    // prints first and last element

Terms of Use

We have invested a lot of time and effort in creating COVID-19 Data Hub, please:

License: GPL-3.