Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
announcement - Col: from records to CSV and vice-versa
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin_jambon@e...>
Subject: announcement - Col: from records to CSV and vice-versa
Col is a syntax library for the conversion between lists of records and 
CSV files with header. CSV (Comma-Separated Values) is a text format 
supported by spreadsheet programs. "records" are represented as OCaml 
records, tuples or objects, all being available and interconvertible.

   main URL:
   development/discussion wiki:

For a demonstration of what the syntax can do, see

Here is a short example which defines a list of 2 records and saves them:

(* File *)
type col t = { x : float;
                y : float;
                title "The Title" : string = "no title" }

let data =
   let x = 1. in
   [ T.create ~x ~y:2. ();
     T.create ~y:4. ~x ~title:"line2" () ]

let _ = T.save_csv "data.csv" data
(* end *)

$ ocamlfind ocamlopt -o testcol -syntax camlp4o -package col -linkpkg
$ ./testcol
$ cat data.csv
x,y,"The Title"
1.,2.,"no title"

This package is not well-documented but I have been using it intensively 
with and gnuplot, and it is stable. My largest record type 
has 49 fields and is still growing!

Have fun!

Martin Jambon, PhD

Edit, bioinformatics wiki