Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x12xml crashing in dataele.py #53

Open
jternent opened this issue Mar 29, 2018 · 0 comments
Open

x12xml crashing in dataele.py #53

jternent opened this issue Mar 29, 2018 · 0 comments

Comments

@jternent
Copy link

Running Anaconda on Windows, Python 3.6.4. Current master branch. Parsing an 837 file using map '837Q3.I.5010.X223.A1.xml', explicit path to map directory (base_path).

During x12xml, I get the below error associated with the following line in dataele.py:
Line 52 : for eElem in et.parse(fd).iter('data_ele'):

It looks like ElementTree is okay either taking the raw path string (os.path.join...) or a file descriptor with the 'rb' mode. 'r' mode gives the same error. To minimize side effects I changed line 48 to :

fd = open(os.path.join(base_path, dataele_file),'rb')

Worked with the next 6 837 files I processed.

I'd submit a pull request, but I'm not certain if this behavior is Windows-only.

Traceback (most recent call last):
File "C:\Users\jtern\Anaconda3\Scripts\x12xml-script.py", line 11, in
load_entry_point('pyx12==2.3.3', 'console_scripts', 'x12xml')()
File "C:\Users\jtern\Anaconda3\lib\site-packages\pyx12-2.3.3-py3.6.egg\pyx12\scripts\x12xml.py", line 120, in main
fd_997=None, fd_html=None, fd_xmldoc=fd_xml, map_path=args.map_path)
File "C:\Users\jtern\Anaconda3\lib\site-packages\pyx12-2.3.3-py3.6.egg\pyx12\x12n_document.py", line 78, in x12n_document
control_map = pyx12.map_if.load_map_file(map_file, param, map_path)
File "C:\Users\jtern\Anaconda3\lib\site-packages\pyx12-2.3.3-py3.6.egg\pyx12\map_if.py", line 1543, in load_map_file
imap = map_if(etree.getroot(), param, map_path)
File "C:\Users\jtern\Anaconda3\lib\site-packages\pyx12-2.3.3-py3.6.egg\pyx12\map_if.py", line 199, in init
self.data_elements = dataele.DataElements(base_path)
File "C:\Users\jtern\Anaconda3\lib\site-packages\pyx12-2.3.3-py3.6.egg\pyx12\dataele.py", line 52, in init
for eElem in et.parse(fd).iter('data_ele'):
File "C:\Users\jtern\Anaconda3\lib\xml\etree\ElementTree.py", line 1196, in parse
tree.parse(source, parser)
File "C:\Users\jtern\Anaconda3\lib\xml\etree\ElementTree.py", line 597, in parse
self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant