Skip to content

Instantly share code, notes, and snippets.

@whitews
Created April 9, 2020 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whitews/1554349b85230be92740ea933f3eb75e to your computer and use it in GitHub Desktop.
Save whitews/1554349b85230be92740ea933f3eb75e to your computer and use it in GitHub Desktop.
parse config
# MRN, ACCN, and Study Date
# sl:mrn,accn,stdt
# MRN, ACCN
sl:mrn,accn
# MRN, Report Date
# sl:mrn,rptdt
import sys
def process_config(in_file):
conf_line = None
with open(in_file) as f:
lines = f.readlines()
for line in lines:
if line.startswith('sl:'):
conf_line = line.strip().split(':')[1]
continue
if conf_line is None:
raise ValueError("You no have good conf file!")
conf_list = conf_line.split(',')
return conf_list
if __name__ == "__main__":
config = process_config(sys.argv[1])
print(config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment