azoner/pyx12

Error parsing 277 file

Closed this issue · 1 comments

I'm trying to parse a 277 file via the command line tool first. It looks like i need to specify a map path but I'm doing something wrong. I get a type error, which I'm guessing it's because i'm on the latest python 3.8.2

ERROR Line:16 SEG:3 - Mandatory loop "Provider of Service Information Trace Identifier" (2200C) missing
2020-08-12 08:34:28,998 ERROR Failed to create 999 response
Traceback (most recent call last):
  File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/x12n_document.py", line 252, in x12n_document
    errh.accept(visit_999)
  File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/error_handler.py", line 101, in accept
    visitor.visit_root_pre(self)
  File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/error_999.py", line 83, in visit_root_pre
    self.wr.Write(isa_seg)
  File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/x12file.py", line 495, in Write
    self._write_isa_segment(seg_data)
  File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/x12file.py", line 582, in _write_isa_segment
    self.fd_out.write(out)
TypeError: a bytes-like object is required, not 'str'
env/193592.20200803220823730_Sample.CLI.277.edi: Failure```

So I ended up working around this. The validation was failing because the 2200C loop is conditional and not mandatory. I need to go into the code to find how to update that.

I ended up figuring this out when going to the x12XML and convert to xml. Verified the output was correct by using the -v flag and ran into another issue.
x12xml -v "env/193592.20200803220823730_Sample.CLI.277.edi"
log:
2020-08-19 14:46:39,741 ERROR Line:16 SEG:3 - Mandatory loop "Provider of Service Information Trace Identifier" (2200C) missing 2020-08-19 14:46:39,747 ERROR Input file had errors.

when removing the verbose flag, it throws an error:

x12xml "env/193592.20200803220823730_Sample.CLI.277.edi" -o output.xml Traceback (most recent call last): File "/home/eddyizm/Documents/py_edi_import/env/bin/x12xml", line 8, in <module> sys.exit(main()) File "/home/eddyizm/Documents/py_edi_import/env/lib/python3.8/site-packages/pyx12/scripts/x12xml.py", line 85, in main if args.verbose > 0: TypeError: '>' not supported between instances of 'NoneType' and 'int'

So I updated the x12xml.py file (line 85):
if args.verbose > 0: logger.setLevel(logging.DEBUG)
to
if args.verbose: if args.verbose > 0: logger.setLevel(logging.DEBUG)
Just trying to move forward, probably doesn't fix the root cause as mentioned above but it does let me convert the file and then move on to the next step of ingesting the file.