# VecOps container of string or TString

**URL:** <https://root-forum.cern.ch/t/vecops-container-of-string-or-tstring/61912>\
**Category:** Newbie\
**Created:** [October 11, 2024, 4:12am UTC](https://root-forum.cern.ch/t/vecops-container-of-string-or-tstring/61912 "2024-10-11T04:12:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hohshita](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/5f9b8f/32.png) [@hohshita](https://root-forum.cern.ch/u/hohshita)\
**Post date:** [October 11, 2024, 4:12am UTC](https://root-forum.cern.ch/t/vecops-container-of-string-or-tstring/61912/1 "2024-10-11T04:12:05Z")

</div>

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](https://root-forum.cern.ch/uploads/short-url/7OXXOp1MnrOxlMFUUn41Tv5hOWk.C) (394 Bytes)  
[readCSVfile\_string.C](https://root-forum.cern.ch/uploads/short-url/xqCtwsZJqALPLaYk9RElzzDo1gR.C) (393 Bytes)  
[20240605\_220000\_230000.txt](https://root-forum.cern.ch/uploads/short-url/cvvRwtUCcCvjCmmUtWrNVI7sXIM.txt) (210 Bytes)

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [October 11, 2024, 11:14am UTC](https://root-forum.cern.ch/t/vecops-container-of-string-or-tstring/61912/2 "2024-10-11T11:14:26Z")

</div>

Hi Hide,

If you take a look at the error

```auto
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

---

<div class="post-metadata">

**Author:** ![hohshita](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/5f9b8f/32.png) [@hohshita](https://root-forum.cern.ch/u/hohshita)\
**Post date:** [October 11, 2024, 1:33pm UTC](https://root-forum.cern.ch/t/vecops-container-of-string-or-tstring/61912/3 "2024-10-11T13:33:39Z")

</div>

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
