Gitlab is now running v13.9.0 - More info -> here <-

Commit 39f20f75 authored by Philippe Veber's avatar Philippe Veber

tk/Dataframe: html rendering

parent 2bf80010
......@@ -118,3 +118,26 @@ let from_file ?(header = `Read_in_file) path =
parse_lines ncols data_lines >>= fun (nrows, cols) ->
let cols = List.zip_exn labels cols in
Ok { nrows ; ncols ; cols }
let to_html d =
let open Tyxml.Html in
let thead =
thead [
tr (List.map d.cols ~f:(fun (label, _) -> td [txt label]))
]
in
let elem col i =
let default = "NA" in
match col with
| Ints t -> Int.to_string t.(i)
| Int_opts t -> Option.value_map ~default ~f:Int.to_string t.(i)
| Floats t -> Float.to_string t.(i)
| Float_opts t -> Option.value_map ~default ~f:Float.to_string t.(i)
| Strings t -> t.(i)
| String_opts t -> Option.value ~default t.(i)
in
let row i =
List.map d.cols ~f:(fun (_, col) -> td [txt (elem col i)])
|> tr
in
table ~thead (List.init (nrows d) ~f:row)
......@@ -21,3 +21,5 @@ val from_file :
?header:[`Read_in_file | `Expect of string list | `Use of string list] ->
string ->
(t, [> `Msg of string]) result
val to_html : t -> [> Html_types.table ] Tyxml.Html.elt
(library
(name codepitk)
(public_name codepi.tk)
(libraries biotk biocaml.ez bos ocaml-r.graphics ocaml-r.grDevices phylogenetics)
(libraries biotk biocaml.ez bos ocaml-r.graphics ocaml-r.grDevices phylogenetics tyxml)
(inline_tests
(deps ../../tests/data/gemma_output.tsv
../../tests/data/gemma_alignment.fa
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment