Got it, many thanks for your help.<br><br><div class="gmail_quote">On Tue, Oct 2, 2012 at 7:59 PM, Oscar Benjamin <span dir="ltr"><<a href="mailto:oscar.j.benjamin@gmail.com" target="_blank">oscar.j.benjamin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Cecilia, I'm sending this again as the first message was sent only<br>
to you (I hadn't realised that your own message was sent only to me as<br>
well). If you want to reply please reply-all to this message.<br>
<div class="im HOEnZb"><br>
On 1 October 2012 17:42, Cecilia Chavana-Bryant<br>
<<a href="mailto:cecilia.chavana@gmail.com">cecilia.chavana@gmail.com</a>> wrote:<br>
</div><div class="im HOEnZb">> On Mon, Oct 1, 2012 at 11:02 AM, Oscar Benjamin <<a href="mailto:oscar.j.benjamin@gmail.com">oscar.j.benjamin@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Sep 30, 2012 11:10 PM, "Cecilia Chavana-Bryant"<br>
>> <<a href="mailto:cecilia.chavana@gmail.com">cecilia.chavana@gmail.com</a>> wrote:<br>
>> ><br>
</div><div class="im HOEnZb">>> > fileDate = data[6][16:26] # location of the creation date on the data<br>
>> > files<br>
>><br>
</div><div class="im HOEnZb">>> What format does fileDate have? I guess it's a string of text from the file. If<br>
>> you can convert it to a datetime (or date) object it will be easy to<br>
>> compare with the dates as required for your calibration file. Can you<br>
>> show us how it looks e.g.<br>
>><br>
>> '12-Nov-2012'<br>
>> or<br>
>> '12/11/12'<br>
>> or something else?<br>
><br>
><br>
> Date is in the following format: dd/mm/yyyy<br>
<br>
</div><div class="HOEnZb"><div class="h5">The standard way to work with dates is to turn the date strings into<br>
Python datetime objects. You can read about those here:<br>
<a href="http://docs.python.org/library/datetime.html" target="_blank">http://docs.python.org/library/datetime.html</a><br>
<br>
datetime objects can be create directly:<br>
<br>
    >>> from datetime import datetime<br>
    >>> start_date = datetime(year=2012, month=11, day=3)<br>
    >>> print start_date<br>
    2012-11-03 00:00:00<br>
<br>
You can also create them from a string:<br>
<br>
    >>> datestring = '10/11/2012'<br>
    >>> experiment_date = datetime.strptime(datestring, '%d/%m/%Y')<br>
    >>> print experiment_date<br>
    2012-11-10 00:00:00<br>
<br>
Once you have two datetime objects you can compare them directly:<br>
<br>
    >>> experiment_date > start_date<br>
    True<br>
    >>> print experiment_date - start_date<br>
    7 days, 0:00:00<br>
<br>
Using this you can check whether the date from the data file is in<br>
between the start and end dates for each of the calibration files and<br>
then choose which calibration file to use.<br>
<br>
<br>
Oscar<br>
</div></div></blockquote></div><br>