# ReadFile in Tree

Hi Everybody
I need to know if i can use readfile to read branches from an txt file where every time i run the number of column changes so the branches changes (the user define the number of column )
How i can do it
thanks

Hi,

if I understand the problem, it is enough to set the proper branch descriptors, for example reading the beginning of the file before invoking the ReadFile method.

Cheers,
Danilo

[quote=“dpiparo”]Hi,

if I understand the problem, it is enough to set the proper branch descriptors, for example reading the beginning of the file before invoking the ReadFile method.

Cheers,
Danilo[/quote]
Hi thanks for reply
So how can i do that
i’m thinking in arrays or for loops but i cant reach the code
thanks again

See the TTree::ReadFile method description (note the case in which the branchDescriptor = “”).

Hi
I read the method description but i don’t know how i can make the number of a tree branches changes depending on the txt file every time it read
thanks

You simply put the description of all your (“data file” specific) branches In the very first line of your text “data file” (the remaining lines should simply contain data for all columns).
Then, you can execute something like:

```TTree *t = new TTree("t", "my tree"); t->ReadFile("MyDataFile.txt"); // all branches are "defined" in the very first line```

Hi Pepe Le Pew
I see , you misunderstand me
i can read the file using readfile
what i want is to read file which its column change depending on the user input
thanks