Created
April 9, 2020 18:11
-
-
Save whitews/1554349b85230be92740ea933f3eb75e to your computer and use it in GitHub Desktop.
parse config
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
# MRN, ACCN, and Study Date | |
# sl:mrn,accn,stdt | |
# MRN, ACCN | |
sl:mrn,accn | |
# MRN, Report Date | |
# sl:mrn,rptdt |
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
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