You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to parse an incoming X12 (834) document. The error is an IndexError but the actual issue seems to be that this file is using a newline character as the segment terminator but newlines are stripped in the "_validate_document" method that is run prior to the parsing step.
There seems to be some discussion on weather or not newline characters are valid segment terminators: kputnam/stupidedi#106
I've gotten things working for me by changing the return statement of the _validate_document method from "return document.replace("\n", "").strip()" to "return document" but I'm not sure if that will change things for other use cases.
What I Did
I have a small test script to start understanding how to use the library:
from badx12 import Parser
parser = Parser()
document = parser.parse_document("test_file.834")
File "t.py", line 4, in <module>
document = parser.parse_document("test_file.834")
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 37, in parse_document
self._separate_and_route_segments()
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 101, in _separate_and_route_segments
self._route_segment_to_parser(segment)
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 114, in _route_segment_to_parser
self._parse_transaction_set_header(segment)
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 193, in _parse_transaction_set_header
self._parse_segment(transaction_header, header_field_list)
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 134, in _parse_segment
raise e
File "/usr/local/lib/python3.6/dist-packages/badx12/parser.py", line 129, in _parse_segment
segment.fields[index].content = value
IndexError: list index out of range
The text was updated successfully, but these errors were encountered:
Description
I'm trying to parse an incoming X12 (834) document. The error is an IndexError but the actual issue seems to be that this file is using a newline character as the segment terminator but newlines are stripped in the "_validate_document" method that is run prior to the parsing step.
There seems to be some discussion on weather or not newline characters are valid segment terminators: kputnam/stupidedi#106
I've gotten things working for me by changing the return statement of the _validate_document method from "return document.replace("\n", "").strip()" to "return document" but I'm not sure if that will change things for other use cases.
What I Did
I have a small test script to start understanding how to use the library:
The text was updated successfully, but these errors were encountered: