Error : when use specific name as output file name in obspy.io.mseed

Hi all,
When I try to write an MSEED file with the filename as its starting time it gave me the following error, But it is working when i give filename in words
[eg:
tr.write(‘test’, format=‘MSEED’)
]
error:

>> st=read(“LSA.IC.mseed”)

>>tr=st[0]
>> tr.write(str(tr.stats.starttime), format=‘MSEED’)
Traceback (most recent call last):

File “”, line 1, in
tr_hourly.write(str(tr.stats.starttime), format=‘MSEED’)

File “C:\ProgramData\Anaconda3\envs\obspy\lib\site-packages\obspy\core\trace.py”, line 990, in write
Stream([self]).write(filename, format, **kwargs)

File “C:\ProgramData\Anaconda3\envs\obspy\lib\site-packages\obspy\core\stream.py”, line 1462, in write
write_format(self, filename, **kwargs)

File “C:\ProgramData\Anaconda3\envs\obspy\lib\site-packages\obspy\io\mseed\core.py”, line 846, in _write_mseed
f = open(filename, ‘wb’)

OSError: [Errno 22] Invalid argument: ‘2020-03-01T00:00:00.019500Z’

How could I write MSEED files with a timestamp as the filenames?

Hi Vivec,

I'm guessing the colon might not be allowed in a filename on Windows.
Try building filenames without dots and colons..

http://docs.obspy.org/master/packages/autogen/obspy.core.utcdatetime.UTCDateTime.strftime.html

e.g.
filename = tr.stats.starttime.strftime('%Y%m%d.mseed')

best,
Tobias

Windows platform does not permit colons in the file name, so no, under Windows you can’t use the timestamp directly in the filename. Pity, I know. You will have to somehow normalize the filename first.

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.