# Help reading wfdisc/css data files

**URL:** https://discourse.obspy.org/t/help-reading-wfdisc-css-data-files/1928
**Category:** Usage Questions
**Created:** [April 28, 2024, 12:22pm UTC](https://discourse.obspy.org/t/help-reading-wfdisc-css-data-files/1928 "2024-04-28T12:22:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jonathan\_Weiss\_PTWC](https://discourse.obspy.org/user_avatar/discourse.obspy.org/jonathan_weiss_ptwc/32/816_2.png) [@Jonathan\_Weiss\_PTWC](https://discourse.obspy.org/u/Jonathan_Weiss_PTWC)
#### Post date: [April 28, 2024, 12:22pm UTC](https://discourse.obspy.org/t/help-reading-wfdisc-css-data-files/1928/1 "2024-04-28T12:22:28Z")

</div>

Hello ObsPy Forum,

I’m trying to load/read wfdisc/css format data so I can convert them to an easier to manipulate format (e.g., sac) for subsequent Earthworm ingestion/processing. I’ve tried following the wfdisc table format specified in [this link](https://nappe.wustl.edu/antelope/css-formats/wfdisc.htm) but I’m getting some cryptic “KeyError” messages (see below). Can anyone provide some guidance or suggestions regarding reading these data? I’m relatively new to ObsPy so perhaps it’s something obvious. I’m also looking at using Pisces but no luck so far. I’ve uploaded a working example [here](https://www.dropbox.com/scl/fi/mshdvhuz4wht0ayus9zok/obspy_example.tgz?rlkey=221q2iipr8rgl6vh8cle9ybn0&dl=0). Any help would be greatly appreciated.

Many thanks,  
Jonathan

> > > st=read(‘/Users/jweiss/Dropbox/PTWC/wfdisc\_stuff/2024001/2024001.mod.wfdisc’,format=‘CSS’,debug\_headers=True)  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “/opt/miniconda3/lib/python3.12/site-packages/decorator.py”, line 232, in fun  
> > > return caller(func, \*(extras + args), \*\*kw)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/util/decorator.py”, line 297, in \_map\_example\_filename  
> > > return func(\*args, \*\*kwargs)  
> > > ^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/stream.py”, line 208, in read  
> > > st = \_generic\_reader(pathname\_or\_url, \_read, \*\*kwargs)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/util/base.py”, line 658, in \_generic\_reader  
> > > generic = callback\_func(pathnames[0], \*\*kwargs)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/decorator.py”, line 232, in fun  
> > > return caller(func, \*(extras + args), \*\*kw)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/util/decorator.py”, line 208, in uncompress\_file  
> > > result = func(filename, \*args, \*\*kwargs)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/stream.py”, line 249, in \_read  
> > > stream, format = \_read\_from\_plugin(‘waveform’, filename, format=format,  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/core/util/base.py”, line 423, in \_read\_from\_plugin  
> > > list\_obj = read\_format(filename, \*\*kwargs)  
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> > > File “/opt/miniconda3/lib/python3.12/site-packages/obspy/io/css/core.py”, line 129, in \_read\_css  
> > > dtype = DTYPE[line[143:145]]

```
        ~~~~~ ^^^^^^^^^^^^^^^

```

KeyError: b’ s’

---

<div class="post-metadata">

### Author: ![megies](https://discourse.obspy.org/user_avatar/discourse.obspy.org/megies/32/9_2.png) [@megies](https://discourse.obspy.org/u/megies)
#### Post date: [April 29, 2024, 8:11am UTC](https://discourse.obspy.org/t/help-reading-wfdisc-css-data-files/1928/2 "2024-04-29T08:11:21Z")

</div>

Your file seems garbled. CSS/WFDISC is fixed format and it’s trying to read the compression type there and it gets `' s'` and when you look in the file there’s `'s4'` there which seems to be the compression type but it’s one column off. So there seem to be issues with the placement of columns in the file.

You can compare with example data under `tests/data` and the specs under `docs/` in our repo:

> **[obspy/obspy/io/css at master · obspy/obspy](https://github.com/obspy/obspy/tree/master/obspy/io/css)**
>
> ObsPy: A Python Toolbox for seismology/seismological observatories. - obspy/obspy

---

<div class="post-metadata">

### Author: ![Jonathan\_Weiss\_PTWC](https://discourse.obspy.org/user_avatar/discourse.obspy.org/jonathan_weiss_ptwc/32/816_2.png) [@Jonathan\_Weiss\_PTWC](https://discourse.obspy.org/u/Jonathan_Weiss_PTWC)
#### Post date: [May 10, 2024, 2:44pm UTC](https://discourse.obspy.org/t/help-reading-wfdisc-css-data-files/1928/3 "2024-05-10T14:44:30Z")

</div>

Hello Tobias,

Many apologies for the super late response. Mahalo nui loa for your quick reply and the useful tips. Pointing me to the tests/data folder in your repo helped as I was able to use the example wfdisc table in tests/data to subtly modify my table and I could then load a few data files without read errors. I think there may be problems with some of the info in my fields because the data look nonsensical when I try to plot them. I will continue to investigate. Also, I was able to write to sac format (both the test data and my files), which is my short-term goal for subsequent analysis. Yay! Thanks again and please stay tuned as I may have some additional questions.

Sincerely,  
Jonathan
