4 from glob
import glob
as ls
5 from argparse
import ArgumentParser
as ap
9 parser.add_argument(
"-p", type=str, help=
'Path to files', default=
'./')
10 args = parser.parse_args()
14 all_files = [i.split(
"/")[-1]
for i
in ls(args.p +
"*")]
18 if 'global_median' in p:
21 runs = set([i.replace(
".txt",
"").
split(
"_")[-1]
for i
in global_meds])
25 f0 =
open(args.p +
'global_median_0_' + r +
'.txt',
'r') 26 f1 = open(args.p + 'global_median_1_' + r +
'.txt',
'r') 27 f2 = open(args.p + 'global_median_2_' + r +
'.txt',
'r') 29 info_0 = f0.readlines()[0] 30 info_1 = f1.readlines()[0] 31 info_2 = f2.readlines()[0] 36 run_num = info_0.split()[0] 37 norm_0 = info_0.split()[1] 39 print(run_num, norm_0, norm_err_0) 41 norm_1 = info_1.split()[1] 44 norm_2 = info_2.split()[1] 49 'channel,tv,norm,norm_err\n',
50 ','.join([
'0', run_num, norm_0, norm_err_0+
"\n" ]),
51 ','.join([
'1', run_num, norm_1, norm_err_1+
"\n" ]),
52 ','.join([
'2', run_num, norm_2, norm_err_2+
"\n" ])
55 outfile =
open(
'globalmedians_run' + run_num +
'.csv',
'w')
56 outfile.writelines(output)
int open(const char *, int)
Opens a file descriptor.
void split(std::string const &s, char c, OutIter dest)