PyCORN icon indicating copy to clipboard operation
PyCORN copied to clipboard

syntax error

Open surbhiisharma opened this issue 5 years ago • 9 comments

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

surbhiisharma avatar Jan 16 '20 21:01 surbhiisharma

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.

pyahmed avatar Jan 16 '20 21:01 pyahmed

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

surbhiisharma avatar Jan 17 '20 00:01 surbhiisharma

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.

pyahmed avatar Jan 17 '20 13:01 pyahmed

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

surbhiisharma avatar Jan 21 '20 21:01 surbhiisharma

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

pyahmed avatar Jan 21 '20 21:01 pyahmed

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 avatar Jan 21 '20 21:01 surbhiisharma

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'

surbhiisharma avatar Jan 22 '20 23:01 surbhiisharma

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

pyahmed avatar Feb 06 '20 14:02 pyahmed

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

fideramirez90 avatar Jan 17 '23 20:01 fideramirez90