* announcement - Col: from records to CSV and vice-versa
@ 2006-04-27 7:43 Martin Jambon
0 siblings, 0 replies; only message in thread
From: Martin Jambon @ 2006-04-27 7:43 UTC (permalink / raw)
To: caml-list
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: http://martin.jambon.free.fr/ocaml.html#col
development/discussion wiki: http://ocaml.pbwiki.com/Col
For a demonstration of what the syntax can do, see
http://martin.jambon.free.fr/col-doc.html
Here is a short example which defines a list of 2 records and saves them:
(* File test.ml *)
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 test.ml -syntax camlp4o -package col -linkpkg
$ ./testcol
$ cat data.csv
x,y,"The Title"
1.,2.,"no title"
1.,4.,line2
$
This package is not well-documented but I have been using it intensively
with openoffice.org and gnuplot, and it is stable. My largest record type
has 49 fields and is still growing!
Have fun!
--
Martin Jambon, PhD
http://martin.jambon.free.fr
Edit http://wikiomics.org, bioinformatics wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-04-27 7:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-27 7:43 announcement - Col: from records to CSV and vice-versa Martin Jambon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox