![]() |
version seven.   http://demongin.org |
How To Install csvtool on OSX 10.6.4
You'll have to compile some things from source, but trust me: it'll be worth it.
Tuesday, 2010-09-07 | Careerism, On the Internet, Programming
| Caml is a general-purpose programming language, designed with program safety and reliability in mind. It is very expressive, yet easy to learn and use. Caml supports functional, imperative, and object-oriented programming styles. |
| caml.inria.fr |
Long story short, I spend most of my day in OSX now.
The situation is obviously sub-optimal--while Cupertino's latest build is closer to being enterprise-ready than Redmod's latest still-birth, it's still no Ubuntu--and frequently requires sysadmin-type intervention, e.g. when I need to manually override Apple's famous "user friendliness" or when I need commercial-strength software on my workstation.
This morning, I got a CSV (pile of hot garbage) from a client that I needed to rapidly query and ultimately re-format. "No problem", I thought, "I'll just fire up ye olde csvtool and make short work of this mess."
I rapidly discovered that not only was csvtool not built in to OSX, but none of the Objective CAML utilities that make professional-strength data manipulation possible are installed by default on OSX.
Start with Homebrew
Homebrew came about half-way to the rescue by providing an objective-caml package:toconnell@Tim-OConnells-MBP ~ $ sudo brew install objective-caml ==> Downloading http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-3.11.2.tar.bz2 File already downloaded and cached to /Library/Caches/Homebrew ==> ./configure --prefix /usr/local/Cellar/objective-caml/3.11.2 ==> make world ==> make opt ==> make opt.opt ==> make install /usr/local/Cellar/objective-caml/3.11.2: 1054 files, 154M, built in 6.7 minutes
Download csvtool Source
Which means that if you want it, you have to compile from source. The first thing to do is download the source tarball from here: http://merjis.com/developers/csv.When I tried to compile the ocaml-csv package, however, I had a dependency problem:
toconnell@Tim-OConnells-MBP ~ $ sudo su sh-3.2# cd Downloads/ocaml-csv-1.1.7 sh-3.2# make ocamlfind ocamlc -g -c csv.mli ocamlfind: Package `threads' not found make: *** [csv.cmi] Error 2
Download findlib Source
The missing package, a quick Googling revealed, belongs to a tool called findlib that is mission-critical for a lot of OCAML tasks.The next step, then, is to download findlib from http://projects.camlcity.org and compile/install it:
sh-3.2# cd findlib-1.2.6 sh-3.2# make ... sh-3.2# make install mkdir -p "/usr/local/bin" mkdir -p "/usr/local/man" ... cp doc/ref-man/META.5 doc/ref-man/site-lib.5 doc/ref-man/findlib.conf.5 /usr/local/man/man5
sh-3.2# cd ocaml-csv-1.1.7
sh-3.2# make
ocamlfind ocamlc -g -c csv.mli
ocamlfind ocamlc -g -c csv.ml
ocamlfind ocamlc -g -a -o csv.cma csv.cmo
ocamlfind ocamlopt -c csv.ml
ocamlfind ocamlopt -a -o csv.cmxa csv.cmx
ocamlfind ocamlc -g csv.cma example.ml -o example
ocamlfind ocamlopt csv.cmxa csvtool.ml -o csvtool
sh-3.2# make install
ocamlfind install csv csv.{cmi,a,cmxa,cma,cmx} META
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/csv.cmx
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/csv.cma
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/csv.cmxa
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/csv.a
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/csv.cmi
Installed /usr/local/Cellar/objective-caml/3.11.2/lib/ocaml/site-lib/csv/META
WARN
This creates an executable file in the current working directory:sh-3.2# pwd /Users/toconnell/Downloads/ocaml-csv-1.1.7 sh-3.2# ./csvtool ./csvtool --help for usage
Otherwise, that's it: four easy steps to running csvtool in OSX Leopard.
