Commit 66dcfe78 authored by erodrigu's avatar erodrigu
Browse files

Script to merge the used_variables.txt files

parent e7443b4f
def get_command_line_arguments():
from argparse import ArgumentParser
help_text = """
This script takes as arguments the path to the vault (-v/--vault)
created by SourcesWithRPE and a flagless list (namelists) of the namelist paths.
"""
parser = ArgumentParser(usage=help_text)
parser.add_argument("-o", "--output", default="used_variables.txt", help="Path to the output file")
parser.add_argument('used_variables', metavar='used_variables', type=str, nargs='+',
help='list of used_variables.txt')
args = parser.parse_args()
return args
if __name__ == "__main__":
args = get_command_line_arguments()
output_file = args.output
used_variables = args.used_variables
# Copy first file contents
with open(used_variables.pop(0)) as _f:
output_lines = _f.readlines()
# Update lines when True
for f in used_variables:
with open(f) as _f:
for i, line in enumerate(_f):
if line.count("T"):
output_lines[i] = line
# Write out the results
with open(output_file, "w") as output:
output.writelines(output_lines)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment