# How can I extract data from root file into simple TXT?

**URL:** <https://root-forum.cern.ch/t/how-can-i-extract-data-from-root-file-into-simple-txt/32978>\
**Category:** Newbie\
**Created:** [March 1, 2019, 3:42pm UTC](https://root-forum.cern.ch/t/how-can-i-extract-data-from-root-file-into-simple-txt/32978 "2019-03-01T15:42:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11112](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/1/d78d45/32.png) [@11112](https://root-forum.cern.ch/u/11112)\
**Post date:** [March 1, 2019, 3:42pm UTC](https://root-forum.cern.ch/t/how-can-i-extract-data-from-root-file-into-simple-txt/32978/1 "2019-03-01T15:42:49Z")

</div>

Good day. I have a dna.root filer, which consist of points of ionisation and exitation x,y,z and energy depositions.

There are a track of 100 keV proton in dna.root file. How can I extract data from root file into a simple txt file with structure:  
x1, y1, z1, energy1  
…  
xN,yN,zN,energyN  
?

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [March 1, 2019, 4:19pm UTC](https://root-forum.cern.ch/t/how-can-i-extract-data-from-root-file-into-simple-txt/32978/2 "2019-03-01T16:19:50Z")

</div>

Hi,  
I assume you have a TTree stored in the .root file (you can think of a TTree as a table with rows and columns).

Here is an example to read the contents of your TTree in python:

> **[Jupyter Notebook Viewer](https://nbviewer.jupyter.org/github/root-project/training/blob/master/OldSummerStudentsCourse/2017/examples/notebooks/TTreeAccess_Example_py.ipynb)**
>
> Check out this Jupyter notebook!

As you read, you can write the values of your branches to a .txt file.
