import sys def fix_vsource(in_file, out_file): t = 0.0 skip_this = False skip = True if "msource" in in_file else False if skip: print("skipping lines for msource.th") with open(in_file) as input: with open(out_file, 'w') as output: for line in input.readlines(): if skip and skip_this is True: skip_this = False output.write(line) continue skip_this = True comps = line.split(maxsplit=1) comps[0] = str(t) output.write(' '.join(comps)) t += 3600.0 if __name__ == '__main__': file = sys.argv[1] fix_vsource(file, f'{file}.fixed') # fix_vsource('vsource.th', 'vsource.th.fixed')