obspy-users Digest, Vol 84, Issue 14

Dear Lion,

Thank you for the time,

you are rigth the part of “len(s_OTIS)” is not good, it is jus “s_OTIS”

I think the part of the code:

“for da in s_OTIS:”

Iterate over the stream, I can see that it list all files with the name “OTIS”

So to save them I need to iterarte over the list to extract the name and write them in order to have all files.

so I tried…

for da in s_OTIS:

for i in range(1:len(s_OTIS):

da.write(da(i).id + “.mseed”, format = ‘mseed’)

but it is not working, can you gime another feedback, thank you a lot for your time.

Best regards


Hi Gonzalo,

I'd really recommend that you work your way through some Python
Tutorials (you can find tons online) and also check out our ObsPy
teaching resources. See links on this page:
You can also check out the 1 hour IRIS webinar on youtube:

And some more Jupyter notebooks from ObsPy training courses, one of the
most recent courses is here:

The main problem with your code (aside from the fact that you keep
posting invalid Python code) is that you keep overwriting your files in
the loop because the filenames are not unique across the loop. So you
should try something like..

for tr in stream:
    filename = '%s_%s.mseed' % (
        tr.id, tr.stats.starttime.strftime('%Y-%m-%dT%H%M%S'))
    tr.write(filename, format='mseed')

If you want to post more questions please take at least the time to post
syntactically valid Python code that you verified locally on your computer.