Convertir el archivo .csv depurado a formato .root

De esta forma transforme el archivo .csv ya depurado. Lo pongo acá, pero en realidad este proceso lo realicé en la terminal del jupyterhub de la redclara; uno, porqué tuve problemas al usar la máquina virtual, mi computador explotaba y segundo, porqué en la línea tree->ReadFile me estaban mostrando muchas líneas de error/warning y jupyter no me las podía mostrar, la terminal si me las mostraba y pude arreglar los conflictos gracias a tener acceso a esos warnings.

In [1]:
%jsroot on
In [2]:
TString dir = gSystem->UnixPathName(__FILE__);
dir.ReplaceAll("meteorite.C","");
dir.ReplaceAll("/./","/");
In [3]:
TFile *f = new TFile("meteorite.root","RECREATE");

Los datos meteorite-landings_clean.csv se obtuvieron mediante el notebook clean_data.ipynb.

Acá es necesario decirle a root el tipo de variable que tiene cada columna dada en la documentación de los datos y adicional, específicar la columna de los índices, llamada acá como entry/I.

In [4]:
TTree *tree = new TTree("data","data from csv file");
// The file inside has ---->   index, name,  id, nametype,  recclass,  mass,  fall,  year,  reclat,  reclong
tree->ReadFile("meteorite-landings_clean.csv","entry/I:name/C:id/I:nametype/I:recclass/C:mass/F:fall/I:year/F:reclat/F:reclong/F",',');
f->Write();
Warning in <TTree::ReadStream>: Couldn't read formatted data in "id" for branch id on line 1; ignoring line
Warning in <TTree::ReadStream>: Read too few columns (3 < 10) in line 1; ignoring line
In [6]:
system("ls -lhrt meteorite*");
-rw-r--r-- 1 student student 4.1M Feb 21 16:16 meteorite-landings.csv
-rw-r--r-- 1 student student 2.1M Feb 23 15:34 meteorite-landings_clean.csv
-rw-r--r-- 1 student student 656K Feb 23 15:36 meteorite.root
In [ ]:
TFile *_file0 = TFile::Open("meteorite.root");
In [ ]: