[Haskell-cafe] Parsing a matrix table with Data.Frames

William Yager will.yager at gmail.com
Wed Jun 6 00:34:11 UTC 2018


What's the issue you're running into? If it's confusion with the API,
hopefully this example is helpful:

> readRow (ParserOptions Nothing "," NoQuoting) "bill,true,true,false" ::
Rec (Either Text) ["Name" :-> Text, "Cat" :-> Bool, "Dog" :-> Bool,
"Goldfish" :-> Bool]

{Right Name :-> "bill", Right Cat :-> True, Right Dog :-> True, Right
Goldfish :-> False}


Requires OverloadedStrings, DataKinds, TypeOperators.


If you then want to extract data you can then do something like


> rget (Proxy :: Proxy ("Name" :-> Text)) row

Right Name :-> "bill"


I assume there is some easier API for this (looks like via template
haskell?). Seems kind of sad if there's no convenient way to do things
without using TH, but I don't see anything obvious.


--Will



On Tue, Jun 5, 2018 at 5:58 PM, Tyson Whitehead <twhitehead at gmail.com>
wrote:

> I have a case where some of my data is stored in CSV matrix form like this
> example of a table telling whether person i has pet j
>
> ,cat,dog,goldfish
> bill,true,true,false
> sue,false,true,true
> fred,false,false,true
>
> I can't see any obvious way to read this sort of thing in with the
> Data.Frames package.  Would love to be told differently.
>
> Thanks!  -Tyson
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180605/bd6add87/attachment.html>


More information about the Haskell-Cafe mailing list