# obspy-users Digest, Vol 84, Issue 14

**URL:** <https://discourse.obspy.org/t/obspy-users-digest-vol-84-issue-14/719>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [November 15, 2017, 1:29pm UTC](https://discourse.obspy.org/t/obspy-users-digest-vol-84-issue-14/719 "2017-11-15T13:29:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gonzalo\_antonio\_fern](https://discourse.obspy.org/user_avatar/discourse.obspy.org/gonzalo_antonio_fern/32/407_2.png) [@gonzalo\_antonio\_fern](https://discourse.obspy.org/u/gonzalo_antonio_fern)\
**Post date:** [November 15, 2017, 1:29pm UTC](https://discourse.obspy.org/t/obspy-users-digest-vol-84-issue-14/719/1 "2017-11-15T13:29:46Z")

</div>

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

Gonzalo

---

<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:** [November 15, 2017, 2:44pm UTC](https://discourse.obspy.org/t/obspy-users-digest-vol-84-issue-14/719/2 "2017-11-15T14:44:26Z")

</div>

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:

> **[Tutorial — ObsPy 1.4.2 documentation](https://docs.obspy.org/tutorial/index.html)**

You can also check out the 1 hour IRIS webinar on youtube:

[![](https://discourse.obspy.org/uploads/default/original/2X/5/5a3f061b68986a0eb96bc2dabc20e5947e7356a9.jpeg "ObsPy: A Python Toolbox for Seismology") ](https://www.youtube.com/watch?v=kFwdjfiK4gk)

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

> **[GitHub - krischer/cig\_llnl\_computational\_seismology\_workshop\_obspy\_instaseis](https://github.com/krischer/cig_llnl_computational_seismology_workshop_obspy_instaseis)**
>
> Contribute to krischer/cig\_llnl\_computational\_seismology\_workshop\_obspy\_instaseis development by creating an account on GitHub.

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:  
&nbsp;&nbsp;&nbsp;&nbsp;filename = '%s\_%s.mseed' % (  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tr.id, tr.stats.starttime.strftime('%Y-%m-%dT%H%M%S'))  
&nbsp;&nbsp;&nbsp;&nbsp;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.

best,  
T
