# Exporting Tree Branch into an ASCII file

**URL:** <https://root-forum.cern.ch/t/exporting-tree-branch-into-an-ascii-file/37031>\
**Category:** Newbie\
**Created:** [December 3, 2019, 4:41am UTC](https://root-forum.cern.ch/t/exporting-tree-branch-into-an-ascii-file/37031 "2019-12-03T04:41:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![myless](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/779978/32.png) [@myless](https://root-forum.cern.ch/u/myless)\
**Post date:** [December 3, 2019, 4:41am UTC](https://root-forum.cern.ch/t/exporting-tree-branch-into-an-ascii-file/37031/1 "2019-12-03T04:41:44Z")

</div>

\_ROOT Version: 6.18/04  
\_Platform: ArchLinux 64-Bit  
\_Compiler: linuxx8664gcc

* * *

Hello,

I have a question about TTree::Scan() or just Trees/branches in general.

I have a Tree with many entries called “tree”. I would like to save a specific branch to an ascii file. I found the following link to [TTreePlayer::Scan()](https://root.cern.ch/root/html534/TTreePlayer.html#TTreePlayer:Scan) and it recommended I use:

```auto
tree->SetScanField(0);
tree->Scan("*"); >tree.log

```

I am able to print out the branch to the console using:

```auto
tree->Set
tree->Scan("E_incident");

```

But when using the advice up above I get the following error:

```auto
ROOT_prompt_8:1:19: error: use of undeclared identifier 'tree'
tree->Scan("*"); >tree.log

```

I would like to export the contents of the branch to an Ascii file so I can more easily edit the data. Is there another way to export the contents of a branch into an Ascii file?

Thank you,

Myles

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [December 3, 2019, 9:53am UTC](https://root-forum.cern.ch/t/exporting-tree-branch-into-an-ascii-file/37031/2 "2019-12-03T09:53:40Z")

</div>

You are looking at the doc of an old ROOT version (version 5)

See the update documentation with the procedure to re-direct the output to a file from the ROOT prompt which is valid for ROOT 6 versions:

[https://root.cern.ch/doc/master/classTTreePlayer.html#aa0149b416e4b812a8762ec1e389ba2db](https://root.cern.ch/doc/master/classTTreePlayer.html#aa0149b416e4b812a8762ec1e389ba2db)

Lorenzo

---

<div class="post-metadata">

**Author:** ![myless](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/779978/32.png) [@myless](https://root-forum.cern.ch/u/myless)\
**Post date:** [December 3, 2019, 1:49pm UTC](https://root-forum.cern.ch/t/exporting-tree-branch-into-an-ascii-file/37031/3 "2019-12-03T13:49:47Z")

</div>

This worked. Thank you!
