I need to remove 2 columns (column 41 and 42) from a row when the column count within a segment of the row is > 42. I'm extremely new to Python. How would I add it to this section? I want to add if category = 'ABC' and countFields(line) > 42 the remove columns 41 and 42.
ret = [] for line in file: category = line[0:3] line = line[4:].strip() if category in ('FHS', 'BHS', 'MSH', 'FTS'): continue elif category == 'PID': if _countFields(line) == 18: line += "|" curPatient = _Patient(line) ret.append(curPatient) else: curPatient.addData(line, category) file.close() return ret
Larz60+ write Sep-09-2021, 09:23 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.