# How to put the information TFile.ls() publishes into a list?

**URL:** <https://root-forum.cern.ch/t/how-to-put-the-information-tfile-ls-publishes-into-a-list/12155>\
**Category:** ROOT\
**Created:** [March 28, 2011, 12:05pm UTC](https://root-forum.cern.ch/t/how-to-put-the-information-tfile-ls-publishes-into-a-list/12155 "2011-03-28T12:05:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazyqg](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/e5b9ba/32.png) [@crazyqg](https://root-forum.cern.ch/u/crazyqg)\
**Post date:** [March 28, 2011, 12:05pm UTC](https://root-forum.cern.ch/t/how-to-put-the-information-tfile-ls-publishes-into-a-list/12155/1 "2011-03-28T12:05:21Z")

</div>

Dear pyroot expert:

I have an inputfile Fulltest.root which contains the following information:

Now processing /home/pixel\_dev/PSI\_Software/Output/roc-001/Fulltest.root  
TFile\*\* /home/pixel\_dev/PSI\_Software/Output/roc-001/Fulltest.root  
TFile\* /home/pixel\_dev/PSI\_Software/Output/roc-001/Fulltest.root  
KEY: TParameter IA;1 Named templated parameter type  
KEY: TParameter VA;1 Named templated parameter type  
KEY: TParameter ID;1 Named templated parameter type  
KEY: TParameter VD;1 Named templated parameter type  
KEY: TGraph TempCalibration\_C0;3  
KEY: TGraph TempCalibration\_C0;2  
KEY: TGraph TempCalibration\_C0;1  
KEY: TGraph TempMeasurement\_C0;3  
KEY: TGraph TempMeasurement\_C0;2  
KEY: TGraph TempMeasurement\_C0;1  
KEY: TH2D CalThresholdMap\_C0;8 CalThresholdMap\_C0  
KEY: TH2D CalThresholdMap\_C0;7 CalThresholdMap\_C0

How can I create a list which contains the names of each of those TH2D, TGraph, TParameter? I want to parse the [infile.ls](http://infile.ls)() information but it does not work:

```
    infile = TFile("Fulltest.root",'r')
    list = infile.ls()
    for i in range(len(list)):
           h1 = infile.Get(list[i].split()[2])
           # perform some analysis on h1.

```

Could you show me how could I create such a list in pyroot instead of printing it on the scrren?

Cheers,Gang

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [March 28, 2011, 4:29pm UTC](https://root-forum.cern.ch/t/how-to-put-the-information-tfile-ls-publishes-into-a-list/12155/2 "2011-03-28T16:29:21Z")

</div>

Hi,

[url][Loop over all objects in a ROOT file](https://root-forum.cern.ch/t/loop-over-all-objects-in-a-root-file/10807/1)

Cheers,  
Wim
