Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seg2 read error for NOTE keyword #3174

Closed
1 task done
HZeyen opened this issue Oct 12, 2022 · 1 comment
Closed
1 task done

Seg2 read error for NOTE keyword #3174

HZeyen opened this issue Oct 12, 2022 · 1 comment
Labels
bug confirmed bug .io.seg2
Milestone

Comments

@HZeyen
Copy link

HZeyen commented Oct 12, 2022

Avoid duplicates

  • I searched existing issues

Bug Summary

Hi, I am having problems reading seg2 files if the keyword 'NOTE' exists but has no contents behind :

Initial code (function "parse_free_form" near the end, around line 327 in file seg2.py:

       if key == 'NOTE':
            value = [cleanup_and_decode_string(line)
                     for line in value.split(self.line_terminator)
                     if line]
        else:
            value = cleanup_and_decode_string(value)

I suggest:

        if key == 'NOTE':
            try:
                value = [cleanup_and_decode_string(line)
                         for line in value.split(self.line_terminator)
                         if line]
            except:
                value = ''
        else:
            value = cleanup_and_decode_string(value)

Rec_00001.zip

Code to Reproduce

from obspy.io.seg2 import seg2
filename = "rec_00001.seg2"
st = seg2._read_seg2(filename)

Error Traceback

Traceback (most recent call last):

  File "C:\Users\Hermann\anaconda3\envs\pg\lib\site-packages\spyder_kernels\py3compat.py", line 356, in compat_exec
    exec(code, globals, locals)

  File "c:\sources_2010\python_programs\obspy_error.py", line 13, in <module>
    st = seg2._read_seg2(filename)

  File "C:\Users\Hermann\anaconda3\envs\pg\lib\site-packages\obspy\io\seg2\seg2.py", line 364, in _read_seg2
    st = seg2.read_file(filename)

  File "C:\Users\Hermann\anaconda3\envs\pg\lib\site-packages\obspy\io\seg2\seg2.py", line 83, in read_file
    self.read_file_descriptor_block()

  File "C:\Users\Hermann\anaconda3\envs\pg\lib\site-packages\obspy\io\seg2\seg2.py", line 167, in read_file_descriptor_block
    self.parse_free_form(

  File "C:\Users\Hermann\anaconda3\envs\pg\lib\site-packages\obspy\io\seg2\seg2.py", line 329, in parse_free_form
    for line in value.split(self.line_terminator)

TypeError: must be str or None, not bytes

ObsPy Version?

1.3.0

Operating System?

Windows

Python Version?

3.8.13

Installation Method?

conda

@HZeyen HZeyen added the bug-unconfirmed reported bug that still needs to be confirmed label Oct 12, 2022
@megies megies added bug confirmed bug .io.seg2 and removed bug-unconfirmed reported bug that still needs to be confirmed labels Oct 13, 2022
@QuLogic
Copy link
Member

QuLogic commented Dec 28, 2022

Fixed by #3178.

@QuLogic QuLogic closed this as completed Dec 28, 2022
@QuLogic QuLogic added this to the 1.3.1 milestone Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed bug .io.seg2
Projects
None yet
Development

No branches or pull requests

3 participants