# Exporting a .ROOT file to .txt

**URL:** <https://root-forum.cern.ch/t/exporting-a-root-file-to-txt/50025>\
**Category:** ROOT\
**Tags:** root\
**Created:** [May 19, 2022, 10:36am UTC](https://root-forum.cern.ch/t/exporting-a-root-file-to-txt/50025 "2022-05-19T10:36:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 19, 2022, 10:39am UTC](https://root-forum.cern.ch/t/exporting-a-root-file-to-txt/50025/2 "2022-05-19T10:39:10Z")

</div>

Welcome to the ROOT forum.  
Search for the forum. This question has been asked 1000 times.  
For instance:

> [@How can I convert .root file to .txt file?](https://root-forum.cern.ch/t/how-can-i-convert-root-file-to-txt-file/21371):
>
> smiley Help required! I need help to convert a root file into text file.

> [@convert root file to txt file](https://root-forum.cern.ch/t/convert-root-file-to-txt-file/49926):
>
> Hi, How can I convert root file to txt file, please? That what I did. ofstream file; file.open(“here.txt”); file\<\<energy\<\<endl; but it stored only the value of the last event. Thanks

> [@ROOT file -\> txt format](https://root-forum.cern.ch/t/root-file-txt-format/48959):
>
> Hi, I want to convert root file into text file, Does anyone know how to convert a ROOT file to text format? Thanks a lot

> [@How to convert .root to .txt file?](https://root-forum.cern.ch/t/how-to-convert-root-to-txt-file/30534):
>
> ROOT Version: 6.10 Platform: Ubuntu 16.04 Compiler: Not Provided I got some ‘dump.root’ file and want to change the information to the text file. The program I used, which is ‘GATE’, recommend me to use the commands in the followings: /////////////////////////////////////////////////////////////////////////////////// // // Name this file "dump.cxx" and use as: // // root [0] .x dump.cxx(); \> dump.txt // // Produces "dump.txt" and "dump.xml" files. // void dump(const char \*fname = "dump.…

> [@Convert a root file to a readable txt file](https://root-forum.cern.ch/t/convert-a-root-file-to-a-readable-txt-file/39957):
>
> Hi Everyone, I want to convert my root file to a txt file. I followed the instruction [extract data to txt file](https://root-forum.cern.ch/t/how-to-extract-a-data-from-dna-root-file/16182). My cxx file is like this： void root2txt(const char \*fname = "4lyr1.root", const char \*nname = "Coincidences") { if (!fname || !(\*fname) || !nname || !(\*nname)) return; // just a precaution TFile \*f = TFile::Open(fname, "READ"); if ((!f) || f-\>IsZombie()) { delete f; return; } // just a precaution TTree \*t; f-\>GetObject(nname, t); if (!t) { delete f; return;…

Etc…  
The forum is a great source of answers by itself 🙂  
If you do not find an answer among the existing replies, do not hesitate to ask again.

---

_[View the full topic](https://root-forum.cern.ch/t/exporting-a-root-file-to-txt/50025)._
