I would like to extract date of acquisiton from mzXML and mzML files, using Python. Is it possible e.g. with Pyteomics? pymzml is only for mzML files. Are there other libraries that can do that? I assume of course that the date of acquisition is recored in mzXML/mzML files.

  • 1
    $\begingroup$ Please edit your question and i) add small example input files (they need to be valid mzXML and mzML) and ii) the output you expect from that input so we can test any answers we come up with. $\endgroup$
    – terdon
    Dec 9, 2022 at 20:31
  • $\begingroup$ This question is really targeted at people who know what a mzXML or mzML file is and who use e.g. pyteomics. Also, I don't know how to attach a data file like this to a stackoverflow question. I think, only images can be uploaded. Thanks $\endgroup$
    – Soerendip
    Dec 12, 2022 at 20:04
  • $\begingroup$ You can simply paste a few lines into your question and then use the {} button to format as code. And it isn't a question of showing the format but of having clear input and output requirements so solutions can be tested. $\endgroup$
    – terdon
    Dec 13, 2022 at 9:23
  • $\begingroup$ I don't think that is necessary. $\endgroup$
    – Soerendip
    Dec 13, 2022 at 17:15
  • $\begingroup$ It isn't about necessary, it is about helping others help you. If you include a test file, then we can test our solutions and make sure they actually work. You have the option of making it harder for people to help you, so in that sense it isn't "necessary". But if you want to ask a good, well received question that doesn't get downvoted, then it is necessary. Your call. $\endgroup$
    – terdon
    Dec 13, 2022 at 17:20

2 Answers 2


You should be able to extract anything from mzML and mzXML with Pyteomics. You will have to look at your files and figure out what you need to do, though, because you need to know what element contains the information that you want. I don't often work with mzXML and in the files that I have I do not see an acquisition date at all. With mzML it appears that the <run> element has this information:

<run id="small_raw" defaultInstrumentConfigurationRef="IC1" startTimeStamp="2005-07-20T14:44:22">

So I can get it like this:

In [1]: from pyteomics import mzml

In [2]: with mzml.MzML('tests/test.mzML') as f:
   ...:     print(next(f.iterfind('run', recursive=False))['startTimeStamp'])

P.S. Disclaimer: I am the maintainer of Pyteomics.


pymzml certainly works via Bald et al 2012:

conda install -c bioconda pymzml

Whilst this only works with mzML you simply convert mzXML to pymzml via ProteoWizard

msconvert your_mzXML_file --mzML

It is described here with your previous question with @haci

I believe you managed this via

conda create -n openms -c bioconda openms
FileConverter -in file.mzXML -out file.mzML

I suspect the underlying question is direct parsing in mzXML without the need to perform a conversion from mzXML to mzML or without using Bioconductor

Possibility The following may be of use massspec-toolbox at:


Note, I've not tested nor read this but the repository looks genuine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.