qkitgroup / qkit

Qkit framework
GNU General Public License v2.0
43 stars 46 forks source link

Loading legacy sample files created under Windows fails under Linux #23

Closed fr34q closed 6 years ago

fr34q commented 6 years ago

Problem: Loading .sample files created under Windows fails under Linux due to different line endings ('\n' created in Windows becomes '\r\n' under Linux)

Relevant line of code: https://github.com/qkitgroup/qkit/blob/4f84bc7dc8089e3a674b4dd558d7e340af4d9797/qkit/measure/samples_class.py#L104

Suggested solution: Do not include '\n' in the split delimiter. Instead, strip the remaining string afterwards and replace '\r\n' by '\n' to enable the pickle package to work with it: pickle.loads(filehandle.read().split('<PICKLE PACKET BEGINS HERE>')[1].strip().replace('\r\n', '\n'))