Closed sorenwacker closed 3 years ago
Hi! This aspect is consistent with how you work with file objects.
Accordingly, there is a .close()
method on all readers. You should be able to do:
ms_data.close()
Alternatively, you can use the with
syntax, e.g.:
with mzxml.MzXML(fn) as ms_data:
for data in ms_data:
df = pd.DataFrame({col: np.array(data[col]) for col in cols})
slices.append( df )
This will close the file automatically.
Hi @soerendip, was I able to answer your question?
Yes, thank you. I had not seen the .close() method in the docs, but it makes total sense :-)
Thanks! For reference, the .close()
method is mentioned in the docs here: https://pyteomics.readthedocs.io/en/latest/data.html#general-notes.
I wonder if I have to call some method to close the file? On Linux I did not experience any trouble, but on Windows processed files cannot be deleted.
I open the file with
And then iterate through the data to generate a pandas dataframe. Then the data is stored in a different format.
How can I close the file again? I looked in the documentation, but did not find a related method.