Repository: obspy/obspy

Issue:
CSS format reading / file type detection
Hello,

Was advised on the mailing list to post this issue here.

I've been happily working with CSS format files generated by the Pisces package but have a small issue when trying to read them with ObsPy. Essentially, I get an unknown file format error using 'read' unless I specify what the data format is explicitly, i.e., st = read("file.wfdisc", format = "CSS"). 

Without specifying the format, the full traceback is:

```
TypeError                                 Traceback (most recent call last)
<ipython-input-2-6eef146513fc> in <module>()
----> 1 st = read('/DEMO_data/2018001.DEMO.wfdisc')

<decorator-gen-146> in read(pathname_or_url, format, headonly, starttime, endtime, nearest_sample, dtype, apply_calib, check_compression, **kwargs)

~/anaconda3/lib/python3.6/site-packages/obspy/core/util/decorator.py in _map_example_filename(func, *args, **kwargs)
    299                         except IOError:
    300                             pass
--> 301         return func(*args, **kwargs)
    302     return _map_example_filename
    303 

~/anaconda3/lib/python3.6/site-packages/obspy/core/stream.py in read(pathname_or_url, format, headonly, starttime, endtime, nearest_sample, dtype, apply_calib, check_compression, **kwargs)
    233         pathname = pathname_or_url
    234         for file in sorted(glob(pathname)):
--> 235             st.extend(_read(file, format, headonly, **kwargs).traces)
    236         if len(st) == 0:
    237             # try to give more specific information why the stream is empty

<decorator-gen-147> in _read(filename, format, headonly, **kwargs)

~/anaconda3/lib/python3.6/site-packages/obspy/core/util/decorator.py in uncompress_file(func, filename, *args, **kwargs)
    209     else:
    210         # no compressions
--> 211         result = func(filename, *args, **kwargs)
    212     return result
    213 

~/anaconda3/lib/python3.6/site-packages/obspy/core/stream.py in _read(filename, format, headonly, **kwargs)
    275     """
    276     stream, format = _read_from_plugin('waveform', filename, format=format,
--> 277                                        headonly=headonly, **kwargs)
    278     # set _format identifier for each element
    279     for trace in stream:

~/anaconda3/lib/python3.6/site-packages/obspy/core/util/base.py in _read_from_plugin(plugin_type, filename, format, **kwargs)
    390                 break
    391         else:
--> 392             raise TypeError('Unknown format for file %s' % filename)
    393     else:
    394         # format given via argument

TypeError: Unknown format for file /DEMO_data/2018001.DEMO.wfdisc
```
It seems the automatic file type detection isn't working, something I note was in a thread about 3 years ago (http://lists.swapbytes.de/archives/obspy-users/2015-February/001642.html). However, I'm not sure if this is ObsPy related, or Pisces related.

I've attached files representing a 30 second example here.

System details:
ObsPy 1.1.0, installed via Anaconda Navigator, running on OSX 10.11.6 with Python version is 3.6.4.

Many thanks.

[DEMO_data.zip](https://github.com/obspy/obspy/files/2043136/DEMO_data.zip)






Discussion:

Resolving patch:
diff --git a/obspy/io/css/core.py b/obspy/io/css/core.py
--- a/obspy/io/css/core.py
+++ b/obspy/io/css/core.py
@@ -62,9 +62,9 @@ def _is_css(filename):
             # check every line
             for line in lines:
                 assert(len(line.rstrip(b"\n\r")) == 283)
-                assert(line[26:27] == b".")
+                assert(b"." in line[26:28])
                 UTCDateTime(float(line[16:33]))
-                assert(line[71:72] == b".")
+                assert(b"." in line[71:73])
                 UTCDateTime(float(line[61:78]))
                 assert(line[143:145] in DTYPE)
     except Exception:


Test patch:
diff --git a/obspy/io/css/tests/data/test_css.wfdisc b/obspy/io/css/tests/data/test_css.wfdisc
--- a/obspy/io/css/tests/data/test_css.wfdisc
+++ b/obspy/io/css/tests/data/test_css.wfdisc
@@ -1,6 +1,6 @@
-TESTbe HHZ      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               0               0 2011/01/31       
-TESTbe HHE      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               19200           0 2011/01/31       
-TESTbe HHN      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               38400           0 2011/01/31       
+TESTbe HHZ      1296474900.0             1        1 2011031   1296474959.98800  4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               0               0 2011/01/31       
+TESTbe HHE       1296474900.00000        1        1 2011031   1296474959.98800  4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               19200           0 2011/01/31       
+TESTbe HHN       1296474900.0            1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - s4 - ./                                                               201101311155.10.be.w               38400           0 2011/01/31       
 TESTle HHZ      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - i4 - ./                                                               201101311155.10.le.w               0               0 2011/01/31       
 TESTle HHE      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - i4 - ./                                                               201101311155.10.le.w               19200           0 2011/01/31       
 TESTle HHN      1296474900.0             1        1 2011031  1296474959.988     4800    80.0                     1.0              1.0 3ESPC  - i4 - ./                                                               201101311155.10.le.w               38400           0 2011/01/31