computational-metabolomics / msp2db

Convert MSP files into a database
GNU General Public License v3.0
9 stars 6 forks source link

Issue with python encoder and msp2db library #9

Open hannierpulido opened 2 years ago

hannierpulido commented 2 years ago

Hello, I am testing the msp2db package in Spyder-Python 3.8 and run into this error when trying to convert a .msp library

create_db(file_pth=db_pth)
libdata = LibraryData(msp_pth="C:/Users/hannierp/Downloads/MoNA-export-LC-MS-MS_Negative_Mode.msp", db_pth = db_pth, schema = "mona")
Traceback (most recent call last):

  File "C:\Users\hannierp\AppData\Local\Temp/ipykernel_11124/3969560687.py", line 1, in <module>
    libdata = LibraryData(msp_pth="C:/Users/hannierp/Downloads/MoNA-export-LC-MS-MS_Negative_Mode.msp", db_pth = db_pth, schema = "mona")

  File "C:\Users\hannierp\Anaconda3\lib\site-packages\msp2db\parse.py", line 115, in __init__
    self._parse_files(msp_pth, chunk, db_type, celery_obj=celery_obj,

  File "C:\Users\hannierp\Anaconda3\lib\site-packages\msp2db\parse.py", line 199, in _parse_files
    self.num_lines = line_count(msp_pth)

  File "C:\Users\hannierp\Anaconda3\lib\site-packages\msp2db\utils.py", line 42, in line_count
    for i, l in enumerate(f):

  File "C:\Users\hannierp\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]

UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 6631: character maps to <undefined>

Any leads about this error, it seems a conflict with the python encoder.

Thanks,

Tomnl commented 2 years ago

Hi @hannierpulido, could you provide the file ( or a subset of the file) you are using please

hannierpulido commented 2 years ago

Hi @Tomnl I got the .msp library from here

Thanks,

Tomnl commented 2 years ago

Hi @hannierpulido,

just running on my Linux (ubuntu) machine and not getting any problems. It could be a problem between Unix/Linux and Windows.

Can you run the following command in your Spyder-python 3.8 setup

import sys
sys.getdefaultencoding()

Can I also check how you installed the package?