pyahmed / PyCORN

A script to extract data from ÄKTA/UNICORN result-files (.res)
46 stars 25 forks source link

syntax error #23

Open surbhiisharma opened 4 years ago

surbhiisharma commented 4 years ago

Hi there,

I remember using pycorn to extract data from .res files last year and it worked without any issue. I recently tried to use it again (now with .zip files from UNICORN7) but I keep getting this syntax error:

pycorn-bin.py --extract .csv sample1.res
  File "<stdin>", line 1
    pycorn-bin.py --extract .csv sample1.res
                                       ^
SyntaxError: invalid syntax

I tried using the sample file for more clarity.

I was also wondering if the switch from .res to zip files means I need to use the entire .zip folder or just the 'Result.xml' file

pyahmed commented 4 years ago

pycorn-bin.py --extract .csv sample1.res Try removing the .

pycorn-bin.py --extract csv sample1.res

For UNICORN7 just use the entire zip, don't extract it.

surbhiisharma commented 4 years ago

thank you for such a quick response! I tried what you suggested and I'm still getting a similar error

pycorn-bin.py --extract csv test1.zip
  File "<stdin>", line 1
    pycorn-bin.py --extract csv test1.zip
                              ^
SyntaxError: invalid syntax
pyahmed commented 4 years ago

I just tried with the sample1.res and it works for me. Can you remove any pycorn installations and reinstall and check if that fixes the problem? Seems as if the pycorn file has been modified.

surbhiisharma commented 4 years ago

Hi,

I tried removing pycorn and reinstalling but is still doesn't seem to be working. even pycorn.py -h gives the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'pycorn' is not defined
pyahmed commented 4 years ago

pycorn.py -h wont give you anything as there are no command line options defined in that file.

surbhiisharma commented 4 years ago

Hm, makes sense. I was hoping to see if using the -h argument could help me dig deeper and solve my problem. Do you have any other ideas why this might be happening? Sorry, I'm a little confused myself and don't understand why it's not working.

surbhiisharma commented 4 years ago

I got the sample.res file to work on my windows machine! (I was using a mac earlier and I'm not sure if maybe that was contributing to the issue?)

However, when I try using the zip file instead I get the following error message:

Chromatogram
{'FormatVersion': '9', 'UNICORNVersion': '7.3.0.473'}
added - orig data
added - orig data
Writing: Injection
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts\pycorn-bin.py", line 390, in <module>
    main2()
  File "C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts\pycorn-bin.py", line 375, in main2
    data_writer1(fname, fdata)
  File "C:\Users\AppData\Local\Programs\Python\Python38-32\Scripts\pycorn-bin.py", line 294, in data_writer1
    type = inp[i]['data_type']
KeyError: 'data_type'
pyahmed commented 4 years ago

I'm afraid that file is just a bit different to the UNICORN 7 files that I had when I wrote the script.

fideramirez90 commented 1 year ago

Can anyone help with this? It is when trying to open a zip file from Unicorn 7 results.

Thanks!

pycorn-bin.py --extract csv 1.zip
Traceback (most recent call last):
  File "C:\Users\AppData\Local\Programs\Python\Python310\Scripts\pycorn-bin.py", line 390, in <module>
    main2()
  File "C:\Users\AppData\Local\Programs\Python\Python310\Scripts\pycorn-bin.py", line 368, in main2
    fdata.load()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\pycorn\pycorn.py", line 307, in load
    zip_data = self.zip2dict(input_zip)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\pycorn\pycorn.py", line 368, in zip2dict
    tmp_dict = {i:inp.read(i)}
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1476, in read
    return fp.read()
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 911, in read
    buf += self._read1(self.MAX_N)
  File "C:\Users\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1001, in _read1
    data = self._decompressor.decompress(data, n)
zlib.error: Error -3 while decompressing data: invalid literal/length code