Created
July 24, 2021 17:25
-
-
Save evanroyrees/d98eee61d0256ec41bbd0957becbf511 to your computer and use it in GitHub Desktop.
Module template for munging then writing out an input table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import os | |
import pandas as pd | |
def do_stuff(df: pd.DataFrame) -> pd.DataFrame: | |
return df | |
def main(): | |
parser = argparse.ArgumentParser(description="""Script description""") | |
parser.add_argument("--input", help="Path to input table", required=True) | |
parser.add_argument( | |
"--input-delim", help="Input table delimiter", required=False, default="\t" | |
) | |
parser.add_argument("--output", help="Path to output", required=True) | |
parser.add_argument( | |
"--output-delim", help="Output table delimiter", required=False, default="\t" | |
) | |
args = parser.parse_args() | |
# READ STUFF | |
in_df = pd.read_csv(args.input, sep=args.input_delim) | |
# DO STUFF | |
out_df = do_stuff(in_df) | |
# WRITE STUFF | |
out_df.to_csv(args.output, sep=args.output_delim) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment