ROOT::RDF::MakeCsvDataFrame : conversion problem


ROOT Version: 6.14.04
Platform :MacOSX
Compiler: Not Provided


Any suggestions how I can find the offending line in my csv line ?
Printing the offending line would be helpful.

MacBook-Pro-3:~/src/SaasFee>root winterCard.C
   ------------------------------------------------------------
  | Welcome to ROOT 6.14/04                http://root.cern.ch |
  |                               (c) 1995-2018, The ROOT Team |
  | Built for macosx64                                         |
  | From tags/v6-14-04@v6-14-04, Aug 23 2018, 17:00:44         |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

root [0] 
Processing winterCard.C...
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: stoll: no conversion
int winterCard()
{
auto fileName = "ticket.csv";
auto tdf = ROOT::RDF::MakeCsvDataFrame(fileName);
auto nentries = tdf.Filter("zip_code == 3906").Count();
std::cout << *nentries << " passed all filters" << std::endl;

return 0;
}

Hi Eddy,
I agree the error message does not say much, except indicating that at some point there is a value in the CSV that cannot be correctly read as a long long.

As a starting point, an easy thing to do is printing the entry number at every call of the filter. RDataFrame stores the entry number in a special column called rdfentry_, so you can do something like this:

auto nentries = tdf.Filter("std::cout << rdfentry_ << std::endl; return zip_code == 3906").Count();

Otherwise, since this is an uncaught exception, you could run the macro through gdb to see when and where it is thrown – but to make it the most effective you might want to avoid just-in-time compilation of parts of the event loop, so you could change

tdf.Filter("zip_code == 3906")

to

tdf.Filter([](long long zip_code) { return zip_code == 3906; }, {"zip_code"})

Hope this helps!
Cheers,
Enrico

Hi Enrico,

This rdfentry_ usage is very helpful in debugging.

thanks, Eddy

Hi Enrico,

I just realize now that this _rdfentry might not be available yet because it happens in
the blackbox MakeCsvDataFrame or can I invoke also here the RDataFrame
Foreach like in

MakeCsvDataFrame(...).Foreach([](Long64_t iEntry) {std::cout << "Entry: " << iEntry << std::end;},{"tdfentry_"}};   ?

-Eddy

ps. I can not test it because my upgrade to Mojave is causing problems :frowning:

Hi Eddy,
you can absolutely use rdfentry_ like that (tdfentry_ is the old name, we keep it for backwards compatibility).

However: in a different thread you mention that the zip_code column is numerical but can have "XXXX" values – could those be the values that cannot be converted to long long that the exception is talking about?

It should also be fairly easy to run your script in gdb and inspect the value of the column at the time the exception is thrown.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.