struct TData { long long fCount; int fSYear; int fEYear; }; static std::string fname_csv = "ticket2.txt"; static std::string fname1_root = "ticket1.root"; static std::string fname2_root = "ticket2.root"; static std::string tname = "STB"; //______________________________________________________________________________________ void MakeDataFrame( ROOT::RDF::RNode tdf_csv) { auto calcColumns = [](const std::string &x) { static TPRegexp rl("(\\d{1,2})-Jahreskarte (\\d{4})"); TData d; d.fCount = 0; d.fSYear = 0; d.fEYear = -1; if (x.find("Jahreskarte") != std::string::npos) { const TObjArray *subStrL = rl.MatchS(x); if (subStrL->GetLast()+1 == 3) { const int length = ((TObjString *)subStrL->At(1))->GetString().Atoi(); d.fSYear = ((TObjString *)subStrL->At(2))->GetString().Atoi(); d.fEYear = d.fSYear+length-1; } else { Error("MakeDataFrame","Invalid data entry: %s",x.c_str()); } delete subStrL; } return d; }; // Insert a few columns auto tdf = tdf_csv.Define("data",calcColumns,{"fTicket"}) .Define("fSYear", [](TData &data){return data.fSYear;}, {"data"}) .Define("fEYear", [](TData &data){return data.fEYear;}, {"data"}); tdf.Count(); std::cout << "Column names of tdf before Snapshot: "; std::vector colNames = tdf.GetColumnNames(); for (auto &&name: colNames) {std::cout << name <<" ";} std::cout < colNames2 = tdf2.GetColumnNames(); for (auto &&name: colNames2) {std::cout << name <<" ";} std::cout << std::endl; long long count_sum = 0; tdf1.Foreach([&count_sum](long long count){count_sum += count;},{"fCount"} ); std::cout << "sum counts of Snapshot with {\"fCount\"}: " << count_sum << std::endl; count_sum = 0; tdf2.Foreach([&count_sum](long long count){count_sum += count;},{"fCount"} ); std::cout << "sum counts of Snapshot of everything: " << count_sum << std::endl; }