The aim of this library is to provide functions for extracting csv data from strings, and for extracting columns of data and list of points from csv data. Asuume that you already have valid Csv data. Then
getColumnAsFloats k csvwill extract a list of floating point numbers from column k of the data csv.
In the same vein,
getPointList i j csvwill return a list of points using the data from columns i and column j.
Getting csv data out of a string would be trivial if all data followed reasnoable conventions, as in the case of the data below:
Global Land and Ocean Temperature Anomalies
January-December 1880-2016
Units: Degrees Celsius
Base Period: 1901-2000
Year,Value
1880,-0.12
1881,-0.07
...
2015,0.91
2016,0.95In this example there are four lines of header text, distinguished by the
fact that they contain no commans. At the fifth line, csv data begins,
giving names to the columns. The rest is good data: pairs of numbers.
The function intelligentGet sep str tries its best to return good
csv data from the string str using the separator sep, typically ",".
It returns a tuple (Maybe Csv, Maybe String). If succesful, the return
value is (Just csv, Just header), where csv : Csv is good data and
header is the header as discussed above. More details on this below.
Return column k of Csv data, converted to Floats
Return column k of Csv data.
Extract columns i and j from Csv data and return the corresponding list of points.
Find the DataState of the string str using
a given separator, e.g., "," and attempt to Return
a pair (Just csvData, Just headerString). To do this,
first find the DataState of the input string. If it is
Nothing, representing invalid data, return (Nothing, Nothing).
Otherwise, return (Just csvData, Just headerString)
Notice that if the data consists of a single column, it
assumed to be a time series and so is augmented by prepending
a column 1,2,3, ... using makeSeries.
Return a Csv value for the string after filtering out obvious bad fields (no commaa)