# String on a ttree

**URL:** <https://root-forum.cern.ch/t/string-on-a-ttree/39615>\
**Category:** Newbie\
**Tags:** tree\
**Created:** [May 27, 2020, 5:54am UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615 "2020-05-27T05:54:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mapse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@Mapse](https://root-forum.cern.ch/u/Mapse)\
**Post date:** [May 27, 2020, 5:54am UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/1 "2020-05-27T05:54:04Z")

</div>

Dear all,

I’m using a ttree to read a csv file in which a column is composed by strings. I need those strings to make some if statements. However, the tree reads only 9 characters and the required string has 12 characters. There is some way to increased the number os characters on the tree?

Code:

```auto
void dataRead(){ //TString chamber, int numDate, TString datemeas
   
    // Tree for read date from a csc file.
    TTree *tree = new TTree("Data for scan","Data from csv file"); 
    // Method to read the file .csv with two variables.
   
    tree->ReadFile("Current_Scan_AllData_2019_03_13.csv","CHAMBER_NAME_CMSSW/C,d1/C,d2/C,d3/C,vmon/D,imon/D",',');
    // Variables to put on the tree branch.
    double current, voltage;
    char chamb, date;
    // Setting the branch address with those variables.
    tree->SetBranchAddress("CHAMBER_NAME_CMSSW", &chamb);
    tree->SetBranchAddress("d1", &date);
    tree->SetBranchAddress("imon", &current);
    tree->SetBranchAddress("vmon", &voltage);
........
}

```

kind regards,

* * *

\_ROOT Version: 6.19/01  
_Platform:_ Ubuntu 20.04  
_Compiler:_ gcc 9.3.0

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 27, 2020, 8:28am UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/2 "2020-05-27T08:28:33Z")

</div>

You need something like: `char chamb[100], date[100];`

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [May 27, 2020, 11:34am UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/3 "2020-05-27T11:34:35Z")

</div>

And use “:” (not “,”) to separate the branch elements in ReadFile:

```auto
    tree->ReadFile("Current_Scan_AllData_2019_03_13.csv","CHAMBER_NAME_CMSSW/C:d1/C:d2/C:d3/C:vmon/D:imon/D",',');

```

---

<div class="post-metadata">

**Author:** ![Mapse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@Mapse](https://root-forum.cern.ch/u/Mapse)\
**Post date:** [May 27, 2020, 2:01pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/4 "2020-05-27T14:01:19Z")

</div>

Hi guys,

thank you for the response, but I got the same result =/

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 27, 2020, 2:06pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/5 "2020-05-27T14:06:59Z")

</div>

Attach your “.csv” file for inspection.

---

<div class="post-metadata">

**Author:** ![Mapse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@Mapse](https://root-forum.cern.ch/u/Mapse)\
**Post date:** [May 27, 2020, 2:12pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/6 "2020-05-27T14:12:11Z")

</div>

[Current\_Scan\_AllData\_2019\_03\_13.zip](https://root-forum.cern.ch/uploads/short-url/oBbktAwDIAt2HQAo8LncMa76uTI.zip) (420 Bytes)

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 27, 2020, 2:25pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/7 "2020-05-27T14:25:38Z")

</div>

I don’t get any problem (except for the first line of your “.csv” file which you should remove or add a “#” character in the beginning).

---

<div class="post-metadata">

**Author:** ![Mapse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/e9a140/32.png) [@Mapse](https://root-forum.cern.ch/u/Mapse)\
**Post date:** [May 28, 2020, 12:47pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/8 "2020-05-28T12:47:14Z")

</div>

That’s weird, I can fill the tree but the names are cutted.

e.g: The name “RE+4\_R2\_CH04” appears as RE+4\_R2\_C when I do tree-\>Scan().

Cheers,

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 28, 2020, 12:57pm UTC](https://root-forum.cern.ch/t/string-on-a-ttree/39615/9 "2020-05-28T12:57:46Z")

</div>

[`tree->Scan("*", "", "colsize=20");`](https://root.cern/doc/master/classTTreePlayer.html#aa0149b416e4b812a8762ec1e389ba2db)
