Simple data analysis with reason/ocaml


#1

I’m looking to learn reason/ocaml by doing some simple data analysis. I’m starting with analysing expenses listed in a CSV. I’ve taken a look at ocaml-csv in combination with jupyter, but when I compare with code examples I found using F# it looks much more cumbersome: if I understand correctly there’s no direct access to colums by name all all data is string with ocaml-csv.

Is ocaml-csv the best option for manipulating CSV data in reason/ocaml? Anyone having other suggestions or alternatives? Or am I missing something obvious that would allow me to manipulate CSV formatted data as easily as I hoped it would be in reason/ocaml?

Thanks in advance!


#2

@rbauduin, if you want to write some bindings, https://www.papaparse.com/ in JS is a great CSV library. If your CSV is pretty simple (no escaping, etc…) you could maybe roll your own.

However there might be CSV stuff that I’m not aware of.


#3

Thanks @justgage. But if I understand correctly, papaparse is mainly about parsing CSV, not manipulating data loaded with it. ocaml-csv seems to be somewhat equivalent in that regard.

I’ve looked futher at ocaml-csv, and it seems to be able to address columns by name, but i’m not sure it’s possible to do it on data loaded in memory (seems it would be only possible in the input channel on which a csv file is read).

I’m focusing on a very simple objective: adding up all integers in column 2 of a CSV with a header line. I’m sorry to say that as a newbie, I’m struggling with that when using ocaml-csv…