Skip to content

Commit

Permalink
utility script to convert MET input data headers from upper case to l…
Browse files Browse the repository at this point in the history
…ower case
  • Loading branch information
bikegeek committed Aug 17, 2024
1 parent 2f1aeec commit e036ece
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/convert_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pandas as pd
import argparse
'''
Converts the uppercase MET headers into lower case for command line usage of
agg_stat.py and other statistics modules.
Requires the full path to the input file and a full path to the output file.
'''

def change_header_case(input_args):
'''
Args:
input_args: the argparse argument object containing the input and output filenames
Returns:
None. Creates the MET input file with lower case headers. Saved in the location specified
from the command line arguments
'''

print(f"reading MET input with upper case headers:{input_args.input_file} ")
df = pd.read_csv(input_args.input_file, sep=r"\s+")
uc_cols = df.columns.to_list()
lc_cols = [lc_cols.lower() for lc_cols in uc_cols]
df.columns = lc_cols

df.to_csv(input_args.output_file, sep="\t", index=False)


print(f"saving MET output with lower case headers: {input_args.output_file} ")



if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Changes upper case MET headers into lower case")

parser.add_argument('-i', type=str, dest='input_file', required=True)
parser.add_argument('-o', type=str, dest='output_file', required=True)

input_args = parser.parse_args()
change_header_case(input_args)

0 comments on commit e036ece

Please sign in to comment.