hadd_many_files.py
Go to the documentation of this file.
1 import sys, os
2 
3 
4 
5 destdir="tmp_data"
6 #tempdir="tmp_data/deleteme"
7 #inputdir=""#/pnfs/nova/scratch/users/mcampbel/nova_nofb_check/threshfiles/"
8 
9 commandstring="mkdir " + destdir
10 os.system(commandstring)
11 #commanstring="mkdir " + tempdir
12 #os.system(commandstring)
13 
14 lf = open("tmplist.dat", "r")
15 
16 lines = lf.readlines()
17 
18 counter = 0
19 totcounter = 1
20 #mystring = "ifdh cp -D "
21 firsthadd = 0
22 oldtotal = destdir + "/old_hadd_running_total.root"
23 currenttotal = destdir + "/hadd_running_total.root"
24 mystring = "hadd " + currenttotal
25 for line in lines:
26  #print line
27 
28  if counter < 100:
29  mystring = mystring + " " + line.split("\n")[0]
30  #print mystring
31  counter = counter +1
32 
33  if counter == 100 or totcounter == len(lines) :
34  print counter, totcounter
35 
36  counter = 0
37 
38  if firsthadd == 0 :
39  firsthadd = 1
40  else :
41  mystring = mystring + " " + oldtotal
42 
43  print mystring
44  os.system( mystring)
45  mystring = "hadd " + currenttotal
46  commandstring = "mv " + currenttotal + " " + oldtotal
47  os.system( commandstring)
48 
49  #if totcounter == 6 :
50  #break
51 
52  totcounter = totcounter+1
procfile open("FD_BRL_v0.txt")