-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarter.py
More file actions
55 lines (33 loc) · 1.11 KB
/
starter.py
File metadata and controls
55 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Starter code for writing a simple python cli.
At a minimum, change the name of the script, the read_data,
transform_data, and write_data functions and away you go.
example usage:
python myscript.py -i /path/to/input -o /path/to/output
"""
import argparse
import sys
def parse_args():
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-i',"--in_file", type=str, help=""
)
parser.add_argument('-o',"--out_file", type=str, help="",
default="out.tab"
)
opts = parser.parse_args()
in_file, out_file = opts.in_file, opts.out_file
return in_file, out_file
def read_data(in_file):
raise NotImplementedError
def data_transform(data_obj):
raise NotImplementedError
def write_data(out_file, data_obj):
raise NotImplementedError
def main():
in_file, out_file = parse_args()
data = read_data(in_file)
new_data = data_transform(data)
write_data(out_file, new_data)
if __name__ == "__main__":
sys.exit(main())