Skip to content

Commit

Permalink
Changed format of parsing and added display number of parsed items flag
Browse files Browse the repository at this point in the history
  • Loading branch information
basiekjusz committed Nov 14, 2020
1 parent 9c0c609 commit 5b5c66c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion icd10_xml_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def parse_node(node):

code_match = icd_pattern.match(node["@code"])
if(code_match):
icd_list.append({"code": code_match.group(), "desc": node['name']})
icd_list.append({"code": code_match.group(), "name": node['name']})
else:
parse_item(node)

Expand Down Expand Up @@ -61,6 +61,7 @@ def parse_item(item):

parser.add_argument("path", help="Input file path")
parser.add_argument("-o", "--output", help="Output file path")
parser.add_argument("-n", "--number", action="store_true", help="Display number of parsed items")

args = parser.parse_args()

Expand All @@ -79,3 +80,6 @@ def parse_item(item):
with open(out_path, "w") as ICD10_json:
json.dump(icd_list, ICD10_json, ensure_ascii=False)
ICD10_json.close()

if(args.number):
print("Total number of parsed items:", len(icd_list))
6 changes: 5 additions & 1 deletion icd9_xml_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def parse_node(node):
"""
if("nodes" not in node.keys()):
icd_list.append({"code": node['@code'], "desc": node['name']})
icd_list.append({"code": node['@code'], "name": node['name']})
else:
parse_item(node)

Expand Down Expand Up @@ -46,6 +46,7 @@ def parse_item(item):

parser.add_argument("path", help="Input file path")
parser.add_argument("-o", "--output", help="Output file path")
parser.add_argument("-n", "--number", action="store_true", help="Display number of parsed items")

args = parser.parse_args()

Expand All @@ -64,3 +65,6 @@ def parse_item(item):
with open(out_path, "w") as ICD9_json:
json.dump(icd_list, ICD9_json, ensure_ascii=False)
ICD9_json.close()

if(args.number):
print("Total number of parsed items:", len(icd_list))
2 changes: 1 addition & 1 deletion json/icd10_pl.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion json/icd9_pl.json

Large diffs are not rendered by default.

0 comments on commit 5b5c66c

Please sign in to comment.