# Converting single column text files into TH1F for fitting

**URL:** <https://root-forum.cern.ch/t/converting-single-column-text-files-into-th1f-for-fitting/38037>\
**Category:** ROOT\
**Created:** [February 18, 2020, 6:57pm UTC](https://root-forum.cern.ch/t/converting-single-column-text-files-into-th1f-for-fitting/38037 "2020-02-18T18:57:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [February 18, 2020, 8:59pm UTC](https://root-forum.cern.ch/t/converting-single-column-text-files-into-th1f-for-fitting/38037/2 "2020-02-18T20:59:26Z")

</div>

> [@Filling Histograms with a text file](https://root-forum.cern.ch/t/filling-histograms-with-a-text-file/34190/2):
>
> Try: /\* Usage examples: root [0] .L Am241.cxx root [1] Am241(); // expects "Am241.txt" in the current directory root [1] Am241("/full/path/to/some/Am241.txt"); or simply: root [0] .x Am241.cxx root [0] .x Am241.cxx("/full/path/to/some/Am241.txt") \*/ #include "TGraph.h" #include \<fstream\> void Am241(const char \*file = "Am241.txt") { if ((!file) || (!file[0])) return; // just a precaution TGraph \*g = new TGraph(); g-\>SetTitle("Count Rate;N\_{counts};# occurencies"); double y;…

BTW. There exists the [TGraph::Fit](https://root.cern.ch/doc/master/classTGraph.html#aa978c8ee0162e661eae795f6f3a35589) method.

---

_[View the full topic](https://root-forum.cern.ch/t/converting-single-column-text-files-into-th1f-for-fitting/38037)._
