# Extract specific values from txt files in Pyroot

**URL:** <https://root-forum.cern.ch/t/extract-specific-values-from-txt-files-in-pyroot/35133>\
**Category:** Newbie\
**Created:** [July 11, 2019, 8:52pm UTC](https://root-forum.cern.ch/t/extract-specific-values-from-txt-files-in-pyroot/35133 "2019-07-11T20:52:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollerstop](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/e19b73/32.png) [@rollerstop](https://root-forum.cern.ch/u/rollerstop)\
**Post date:** [July 11, 2019, 8:52pm UTC](https://root-forum.cern.ch/t/extract-specific-values-from-txt-files-in-pyroot/35133/1 "2019-07-11T20:52:29Z")

</div>

So let’s say I have 20 .txt files with almost similar names like data20.txt, data30.txt etc.  
Every file has 5 values in it like: 1 2 3 4 5  
I want to get the first value from every file and fill them into a array so I get plot them later on. I know how to do the plot, I just don’t know how to get the arrays. Can someone help me with that?

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [July 11, 2019, 9:48pm UTC](https://root-forum.cern.ch/t/extract-specific-values-from-txt-files-in-pyroot/35133/2 "2019-07-11T21:48:35Z")

</div>

Hi @rollerstop,  
this looks more like a python(?) question than a ROOT question. I wasn’t sure how to do this off the top of my head, but a quick google got me [this stackoverflow question](https://stackoverflow.com/questions/14676265/how-to-read-a-text-file-into-a-list-or-an-array-with-python), hopefully it applies to your case! 😄

Cheers,  
Enrico
