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
Description
I'm receiving mzML files as bytes, wrapping these in io.BytesIO, and then passing that to pymzml.run.Reader:
reader=pymzml.run.Reader(io.BytesIO(mzml_bytes))
This sometimes raises the following exception:
ParseError: noelementfound: line1, column0
Why
Some of the mzML files I'm using do not have line breaks - i.e. they are all on a single line, and the _guess_encoding function breaks these. Looking at the pymzml source, the io.BytesIO objects travel through this line, which in turn calls the culprit, _guess_encoding:
Version
pymzml: 2.5.10
Python: 3.11.7
Description
I'm receiving mzML files as
bytes
, wrapping these inio.BytesIO
, and then passing that topymzml.run.Reader
:This sometimes raises the following exception:
Why
Some of the mzML files I'm using do not have line breaks - i.e. they are all on a single line, and the
_guess_encoding
function breaks these. Looking at thepymzml
source, theio.BytesIO
objects travel through this line, which in turn calls the culprit, _guess_encoding:After the
.readline()
, there's no data left in theBytesIO
if the file has no line breaks, and thus the later XML parsing fails.Workaround/fix
I'm current inserting a line break at the start of the XML data before passing it to
pymzml
:I believe this could also be fixed by just adding
mzml_file.seek(0)
after the offending line.The text was updated successfully, but these errors were encountered: