Permalink
Browse files

add file via cmd arguments

  • Loading branch information...
Jeremy Heminger Jeremy Heminger
Jeremy Heminger authored and Jeremy Heminger committed Nov 5, 2018
1 parent cb49236 commit 3d48a52b6bbc8bdf5467d7466d403c375a380774
Showing with 25 additions and 5 deletions.
  1. +25 −5 hippaa.edi.3.py
@@ -1,6 +1,7 @@
import array
import string
import sys
import getopt
# http://code.activestate.com/recipes/299485-parsing-out-edi-messages/
@@ -189,12 +190,31 @@ def __next__(self):
except TypeError:
raise BadFile('Corrupt characters found in data or unexpected EOF')
if __name__ == '__main__':
# Sample usage
message = Parser('doitbest.edi')
'''
Get the file from the CMD and then run it
'''
def main(argv) :
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile="])
except getopt.GetoptError:
print ('hippaa.edi.3.py -i <inputfile>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print ('hippaa.edi.3.py -i <inputfile>')
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
message = Parser('files/' + arg)
for segment in message:
if(len(message.delimiters) > 1):
elements = segment.split(message.delimiters[1])
# Dispatch based on elements[0]...
print(elements)
print(elements)
if __name__ == '__main__':
main(sys.argv[1:])

0 comments on commit 3d48a52

Please sign in to comment.