jxxcarlson/elm-stat/3.1.0

NOTE: the latest version is 6.0.3

RawData

The purpose of the RawData module is to intelligently extract a data table, column headers, and metadata from a string representing data in one of several formats — csv, tab-delimited, or space-delimited. With the second, one can extract a list of Points in the xy plane from a data table.

type alias RawData =
{ metadata : List String
, columnHeaders : List String
, data : Table String
}

A RawData value consists of metadata, columnHeaders, and data. The first two are lists of strings, while the last is a list of records, where a record is a lest of strings.

get : String -> Maybe RawData

`Here is an example of how one extracts RawData from a string:

> import SampleData
> import RawData
> RawData.get SampleData.temperature
     Just {
         columnHeaders = ["Year","Value"]
       , metadata = ["Global Land and Ocean Temperature Anomalies"
                     ,"January-December 1880-2016"
                     ,"Units: Degrees Celsius"
                    ]
       , rawData = [["1880","-0.12"],["1881","-0.07"],["1882","-0.08"]
                    ["1883","-0.15"], ...
toData : Int -> Int -> RawData -> Maybe Data

Examples:

> SampleData.eb2 |> RawData.get
  Just { columnHeaders = ["x","y"]
      , data = [["0","1.0"],["0","0.9"],["1","1.8"],["0","1.0"],["1","2.0"]
               ,["1","2.2"],["0","1.1"]]
      , metadata = [] }