# ROOT file -\> txt format

**URL:** <https://root-forum.cern.ch/t/root-file-txt-format/48959>\
**Category:** ROOT\
**Created:** [February 26, 2022, 8:15pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959 "2022-02-26T20:15:06Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![Spring\_127](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Spring\_127](https://root-forum.cern.ch/u/Spring_127)\
**Post date:** [March 2, 2022, 3:10pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/22 "2022-03-02T15:10:45Z")

</div>

Thank you for your guidance,  
The root files that are generated at the end of the execution are 3 files:

output.root  
output\_t0.root  
output\_t1.root

The following command for the output.root file  
Runs properly:

root -b -l -q ‘dump.cxx (“dump.txt”, “output.root”, “ntuple / ntuple\_1”)’

The dump.txt and dump.xml files are created and display the following message in the terminal:

+++++++++++++++++++++++++  
Processing dump.cxx (“dump.txt”, “output.root”, “ntuple / ntuple\_1”) …  
File \<dump.txt\> created  
Info in : ROOT file dump.xml has been created

+++++++++++++++++++++++++

But for files:

output\_t0.root  
output\_t1.root

Displays the following error:

++++++++++++++++++++++++++++

Processing dump.cxx(“dump.txt”, “output\_t1.root”, “ntuple/ntuple\_1”)…  
File \<dump.txt\> created  
Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Error in TBranch::TBranch::WriteBasketImpl: basket’s WriteBuffer failed.

Info in TTree::SaveAs: ROOT file dump.xml has been created

++++++++++++++++++++++++++++++

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [March 2, 2022, 4:03pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/23 "2022-03-02T16:03:57Z")

</div>

See [https://github.com/root-project/root/issues/10024](https://github.com/root-project/root/issues/10024) for `TTree::SaveAs` explicit disabling request.

---

<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:** [March 2, 2022, 5:23pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/24 "2022-03-02T17:23:59Z")

</div>

@pcanal Note that, at least in some cases, it can work without reporting any errors, e.g., try `ntuple->SaveAs("dump.xml")` for the “hsimple.root” (from the “tutorials”).

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [March 2, 2022, 7:09pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/25 "2022-03-02T19:09:44Z")

</div>

> Note that, at least in some cases, it can work without reporting any errors,

I see that too … However the xml file only contains the TTree object (meta-data) and none of the data. (i.e. unlikely to be the intended content)

---

<div class="post-metadata">

**Author:** ![Spring\_127](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Spring\_127](https://root-forum.cern.ch/u/Spring_127)\
**Post date:** [March 2, 2022, 7:57pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/26 "2022-03-02T19:57:22Z")

</div>

Thank you for your valuable help, please help with the root file in the following format:

ttaching file output.root as \_file0 …  
(TFile \*) 0x5556a033ddc0  
TFile \*\* output.root  
TFile \* output.root  
KEY: TH1D 1; 1 edep  
KEY: TH1D 2; 1 cl size  
KEY: TH1D 3; 1 Nsb  
KEY: TH1D 4; 1 Ndb  
KEY: TH1D 5; 1 Cdb

The .txt file will not be generated when I run the following command in the terminal:

root -b -l -q ‘dump.cxx (“dump.txt”, “output.root”, “1/ 1”)’

With respect ,  
Spring\_127

---

<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:** [March 2, 2022, 8:02pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/27 "2022-03-02T20:02:43Z")

</div>

`root -b -l -q output.root -e 'TH1 *h; gFile->GetObject("1", h); h->Print("all");' > h.out.txt`

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [March 2, 2022, 8:11pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/28 "2022-03-02T20:11:46Z")

</div>

you could definitely use `root2yoda` for that:

- [https://go-hep.org/x/hep/cmd/root2yoda](https://go-hep.org/x/hep/cmd/root2yoda)

which can be downloaded from:

- [https://go-hep.org/dist/latest](https://go-hep.org/dist/latest)  
(then, choose the one for your operating system.)

---

<div class="post-metadata">

**Author:** ![Spring\_127](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Spring\_127](https://root-forum.cern.ch/u/Spring_127)\
**Post date:** [March 2, 2022, 9:11pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/29 "2022-03-02T21:11:51Z")

</div>

Dear Wile\_E\_Coyote,

Thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![Spring\_127](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Spring\_127](https://root-forum.cern.ch/u/Spring_127)\
**Post date:** [March 2, 2022, 9:45pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/30 "2022-03-02T21:45:11Z")

</div>

dear sbinet,  
Thank you for your help.

$ ./root2yoda-linux\_amd64.exe output.root out.yoda

* * *

root2yoda: processing output.root  
BEGIN YODA\_HISTO1D\_V2 /2  
Path: /2  
.  
.  
.  
.  
.  
root2yoda: processing out.yoda  
root2yoda: failed to open [out.yoda]: riofs: unable to open “out.yoda”: riofs: no ROOT plugin to open [out.yoda] (scheme=)

* * *

The output file was not created, only displayed on the terminal.

With respect,  
zj

---

<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:** [March 2, 2022, 9:54pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/31 "2022-03-02T21:54:52Z")

</div>

`./root2yoda-linux_amd64.exe output.root > out.yoda`  
`./root2yoda-linux_amd64.exe -o out.yoda output.root`

---

<div class="post-metadata">

**Author:** ![Spring\_127](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Spring\_127](https://root-forum.cern.ch/u/Spring_127)\
**Post date:** [March 2, 2022, 10:03pm UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/32 "2022-03-02T22:03:06Z")

</div>

Dear Wile\_E\_Coyote,

Thank you very much for your help.

With respect,  
zj

---

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [March 3, 2022, 7:44am UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/33 "2022-03-03T07:44:34Z")

</div>

did it work for what you wanted to achieve (at least for the histograms part)?

for the `TTree` part, `root2csv` could be an option (if the `TTree` is simple enough: just scalars, not `std::vector<T>` nor `arrays` or `structs`.)

(`root2npy` could be an option as well, but…)  
it all depends on what you want to do with those ASCII files.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [March 17, 2022, 7:44am UTC](https://root-forum.cern.ch/t/root-file-txt-format/48959/34 "2022-03-17T07:44:42Z")

</div>

Closed on March 17, 2022, 7:44am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

[Previous page](https://root-forum.cern.ch/t/root-file-txt-format/48959.md?page=1)
