# How to convert .root to .txt file?

**URL:** <https://root-forum.cern.ch/t/how-to-convert-root-to-txt-file/30534>\
**Category:** ROOT\
**Created:** [September 4, 2018, 5:22am UTC](https://root-forum.cern.ch/t/how-to-convert-root-to-txt-file/30534 "2018-09-04T05:22:39Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [September 4, 2018, 7:43am UTC](https://root-forum.cern.ch/t/how-to-convert-root-to-txt-file/30534/3 "2018-09-04T07:43:47Z")

</div>

alternatively, you could use [go-hep.org/x/hep/rootio/cmd/root-dump](https://go-hep.org/x/hep/rootio/cmd/root-dump), from [Go-HEP](https://go-hep.org).

examples:

```auto
$> root-ls graphs.root 
=== [graphs.root] ===
version: 60806
TGraph tg graph without errors (cycle=1)
TGraphErrors tge graph with errors (cycle=1)
TGraphAsymmErrors tgae graph with asymmetric errors (cycle=1)

$> root-dump graphs.root
>>> file[graphs.root]
key[000]: tg;1 "graph without errors" (TGraph)
BEGIN YODA_SCATTER2D /tg
Path=/tg
Title=graph without errors
Type=Scatter2D
# xval xerr- xerr+ yval yerr- yerr+
1.000000e+00	0.000000e+00	0.000000e+00	2.000000e+00	0.000000e+00	0.000000e+00
2.000000e+00	0.000000e+00	0.000000e+00	4.000000e+00	0.000000e+00	0.000000e+00
3.000000e+00	0.000000e+00	0.000000e+00	6.000000e+00	0.000000e+00	0.000000e+00
4.000000e+00	0.000000e+00	0.000000e+00	8.000000e+00	0.000000e+00	0.000000e+00
END YODA_SCATTER2D

key[001]: tge;1 "graph with errors" (TGraphErrors)
BEGIN YODA_SCATTER2D /tge
[...]

$> root-ls gauss-h1.root 
=== [gauss-h1.root] ===
version: 60806
TH1D h1d h1d (cycle=1)
TH1F h1f h1f (cycle=1)
TH1F h1d-var h1d-var (cycle=1)
TH1F h1f-var h1f-var (cycle=1)

$> root-dump gauss-h1.root
>>> file[gauss-h1.root]
key[000]: h1d;1 "h1d" (TH1D)
BEGIN YODA_HISTO1D /h1d
Path=/h1d
Title=h1d
Type=Histo1D
# Mean: 2.812016e-02
# Area: 1.100600e+04
# ID ID sumw sumw2 sumwx sumwx2 numEntries
Total Total 1.100600e+04	1.211000e+04	3.094905e+02	7.128989e+04	10004
Underflow	Underflow	2.000000e+00	2.000000e+00	0.000000e+00	0.000000e+00	2
Overflow	Overflow	4.000000e+00	8.000000e+00	0.000000e+00	0.000000e+00	2
# xlow xhigh sumw sumw2 sumwx sumwx2 numEntries
-4.000000e+00	-3.200000e+00	6.600000e+00	7.260000e+00	0.000000e+00	0.000000e+00	6
-3.200000e+00	-2.400000e+00	7.260000e+01	7.986000e+01	0.000000e+00	0.000000e+00	66
-2.400000e+00	-1.600000e+00	5.434000e+02	5.977400e+02	0.000000e+00	0.000000e+00	494
-1.600000e+00	-8.000000e-01	1.708300e+03	1.879130e+03	0.000000e+00	0.000000e+00	1553
-8.000000e-01	2.220446e-16	3.130600e+03	3.443660e+03	0.000000e+00	0.000000e+00	2846
0.000000e+00	8.000000e-01	3.136100e+03	3.449710e+03	0.000000e+00	0.000000e+00	2851
8.000000e-01	1.600000e+00	1.753400e+03	1.928740e+03	0.000000e+00	0.000000e+00	1594
1.600000e+00	2.400000e+00	5.401000e+02	5.941100e+02	0.000000e+00	0.000000e+00	491
2.400000e+00	3.200000e+00	1.012000e+02	1.113200e+02	0.000000e+00	0.000000e+00	92
3.200000e+00	4.000000e+00	7.700000e+00	8.470000e+00	0.000000e+00	0.000000e+00	7
END YODA_HISTO1D

key[001]: h1f;1 "h1f" (TH1F)
[...]

```

it should work with most of `TTrees` as well.

you can install it (once you have [Go](https://golang.org/doc/install)) like so:

```auto
$> go get go-hep.org/x/hep/rootio/cmd/root-dump

```

otherwise, I have compiled it for a couple of OS/Arch here:

- [https://cern.ch/binet/go-hep/rootio/root-dump-darwin-amd64.exe](https://cern.ch/binet/go-hep/rootio/root-dump-darwin-amd64.exe)
- [https://cern.ch/binet/go-hep/rootio/root-dump-linux-amd64.exe](https://cern.ch/binet/go-hep/rootio/root-dump-linux-amd64.exe)
- [https://cern.ch/binet/go-hep/rootio/root-dump-windows-amd64.exe](https://cern.ch/binet/go-hep/rootio/root-dump-windows-amd64.exe)

hth,  
-s

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-convert-root-to-txt-file/30534)._
