But if I would like to avoid the problem, best will be to read directly from the original dump of the database file which is in csv format.
Would that be possible?
See: TTree::ReadFile
BTW. I’m afraid it will also choke on UTF-8 encoded files (so, you need to make sure that you have simple ASCII csv files) and I don’t think it will accept the string “NULL” as a numerical value 0.
Hmm, where do I put the delimiter = ‘,’ ?
I tried, std::ifstream ifs(Form("%sTestLines_faraBoatName.csv", dir.Data()),’;’, std::ifstream::in);
but doesn’t work, silly me
Sor
I don’t understand what you’re trying to do. See: std::ifstream
Post your csv file here, if it doesn’t work with TTree::ReadFile.
Here is the csv file, is a mixture of diferent types of data, eand the second column, which are names were written in different ways, not all of them are two different names
fewLines.csv (2.3 KB)
{
TFile *f = TFile::Open("fewLines.root", "RECREATE");
TTree *t = new TTree("t", "A tree from fewLines.csv");
t->ReadFile("fewLines.csv",
"Index/I;Name/C;FHS/F;Spe;STI;Date/C;WDir;WSpe/F;Slip;WHgh;SSta/I;Drfw/F;Draf",
';');
// t->Print();
// t->Scan("*");
t->Write();
delete f; // automatically deletes "t", too
}
Is working fine for few lines, but I just got the dump from the DB , still the problem of NULL, managed to find and replace with 0 but somehow the last two columns are not read. When I made t->Scan(*) and redirect the output to a text file, I see he is reading correctly the last two columns value.