cov19data

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

cov19data -- Importing WHO COVID-2019 Cases Global Data

Build Status GitHub license GitHub release

Usage

Import This Package
import "github.com/spiegel-im-spiegel/cov19data/client"
Get COVID-2019 Global Data (raw data) from WHO Web Site
package main

import (
    "fmt"
    "io"
    "os"

    "github.com/spiegel-im-spiegel/cov19data/client"
)

func main() {
    r, err := client.Default().WHOCasesData()
    if err != nil {
        fmt.Printf("%+v\n", err)
        return
    }
    defer r.Close()

    if _, err := io.Copy(os.Stdout, r); err != nil {
        fmt.Println()
    }
}
Import COVID-2019 Global Data from WHO Web Site to Structured Dataset.
package main

import (
    "bytes"
    "fmt"
    "io"
    "os"
    "time"

    "github.com/spiegel-im-spiegel/cov19data"
    "github.com/spiegel-im-spiegel/cov19data/client"
    "github.com/spiegel-im-spiegel/cov19data/entity"
    "github.com/spiegel-im-spiegel/cov19data/values"
)

func main() {
    data, err := cov19data.ImportWHOCSV(
        client.Default(),
        entity.WithFilterPeriod(
            values.NewPeriod(
                values.NewDate(2020, time.Month(9), 1),
                values.Yesterday(),
            ),
        ),
        entity.WithCountryCode(values.CC_JP),
        entity.WithRegionCode(values.WPRO),
    )
    if err != nil {
        fmt.Fprintf(os.Stderr, "%+v\n", err)
        return
    }

    b, err := entity.ExportWHOCSV(data)
    if err != nil {
        fmt.Fprintf(os.Stderr, "%v\n", err)
        return
    }
    if _, err := io.Copy(os.Stdout, bytes.NewReader(b)); err != nil {
        fmt.Println()
    }
    // Output:
    // Date_reported,Country_code,Country,WHO_region,New_cases,Cumulative_cases,New_deaths,Cumulative_deaths
    // 2020-09-01,JP,Japan,WPRO,527,68392,17,1296
    // 2020-09-02,JP,Japan,WPRO,609,69001,11,1307
    // 2020-09-03,JP,Japan,WPRO,598,69599,12,1319
    // 2020-09-04,JP,Japan,WPRO,669,70268,11,1330
    // 2020-09-05,JP,Japan,WPRO,608,70876,19,1349
    // 2020-09-06,JP,Japan,WPRO,543,71419,8,1357
    // 2020-09-07,JP,Japan,WPRO,437,71856,6,1363
}
Make Histogram data by COVID-2019 Global Data from WHO Web Site.
package main

import (
    "bytes"
    "fmt"
    "io"
    "os"
    "time"

    "github.com/spiegel-im-spiegel/cov19data"
    "github.com/spiegel-im-spiegel/cov19data/client"
    "github.com/spiegel-im-spiegel/cov19data/entity"
    "github.com/spiegel-im-spiegel/cov19data/histogram"
    "github.com/spiegel-im-spiegel/cov19data/values"
)

func main() {
    h, err := cov19data.MakeHistogramWHO(
        client.Default(),
        values.NewPeriod(
            values.NewDate(2020, time.Month(8), 1),
            values.Yesterday(),
        ),
        7, //step by 7 days
        entity.WithCountryCode(values.CC_JP),
        entity.WithRegionCode(values.WPRO),
    )
    if err != nil {
        fmt.Printf("%+v\n", err)
        return
    }

    b, err := histogram.ExportHistCSV(h)
    if err != nil {
        fmt.Printf("%+v\n", err)
        return
    }
    if _, err := io.Copy(os.Stdout, bytes.NewReader(b)); err != nil {
        fmt.Println()
    }
    // Output:
    // Date_from,Date_to,Cases,Deaths
    // 2020-07-28,2020-08-03,8698,16
    // 2020-08-04,2020-08-10,9303,35
    // 2020-08-11,2020-08-17,7677,52
    // 2020-08-18,2020-08-24,6840,82
    // 2020-08-25,2020-08-31,5358,98
    // 2020-09-01,2020-09-07,3991,84
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportTokyoCSV added in v0.2.0

func ImportTokyoCSV(c *client.Client, opts ...entity.FiltersOptFunc) ([]entity.TokyoData, error)

ImportWHOCSV function returns WHO COVID-19 global data from WHO site.

func ImportWHOCSV

func ImportWHOCSV(c *client.Client, opts ...entity.FiltersOptFunc) ([]entity.WHOGlobalData, error)

ImportWHOCSV function returns WHO COVID-19 global data from WHO site.

func MakeHistogramTokyo added in v0.2.0

func MakeHistogramTokyo(c *client.Client, period values.Period, span int, opts ...entity.FiltersOptFunc) ([]*histogram.HistData, error)

MakeHistogramTokyo function returns Tokyo patients data from Web site.

func MakeHistogramWHO added in v0.2.0

func MakeHistogramWHO(c *client.Client, period values.Period, span int, opts ...entity.FiltersOptFunc) ([]*histogram.HistData, error)

MakeHistogramWHO function returns WHO COVID-19 global data from WHO site.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL