VecOps container of string or TString

Dear ROOT experts,

I am trying to read a text file using the RDF::FromCSV method.
For elements of string, the VecOps container of type string works,
but the VecOps container of type TString does not seem to work.
Why is this?
It would be nice if both would work.

Two simple programs are attached.
The only difference between the two programs is the data type when storing data in the VecOps container by the Take method (line 6).

The usage is as follows:

$ root -l
root[0] .L readCSVfile_string.C
root[1] readCSVfile(“20240605_220000_230000.txt”)
2024-06-05 22:00:00,189186537,77.6322
2024-06-05 22:00:01,189186538,77.7024
2024-06-05 22:00:02,189186539,77.6088
2024-06-05 22:00:03,189186540,77.6088
2024-06-05 22:00:04,189186541,77.5151
(int) 0
root[2] .q

$ root -l
root[0] .L readCSVfile_TString.C
root[1] readCSVfile(“20240605_220000_230000.txt”)
Error in TRint::HandleTermInput(): std::runtime_error caught: The type selected for column “date” does not correspond to column type, which is std::string
root[2] .q

Best regards,
Hide

ROOT Version: 6.30/02
Platform: AlmaLinux 8.9
Compiler: gcc 8.5.0 20210514

readCSVfile_TString.C (394 Bytes)
readCSVfile_string.C (393 Bytes)
20240605_220000_230000.txt (210 Bytes)

Hi Hide,

If you take a look at the error

Error in TRint::HandleTermInput(): std::runtime_error caught: The type selected for column “date” does not correspond to column type, which is std::string

It seems to suggest to use std::string rather than TString perhaps?

Cheers,
D

Dear Danilo,

Thank you for your quick reply !
As you pointed out, using the string type works well.
I will use the string type instead of the TString type.

Best regards,
Hide