@@ -0,0 +1,1852 @@
+%22%22%22Helper to process RSPlayer logs for Programme Return.%0D%0A%0D%0APut RSPlayer logs into some folder, change to it, open a Python prompt and paste%0D%0Ain this code.  Be sure that the logs contain only the data you want (ie trim the%0D%0Astart and end to get rid of data outside of the reporting period).%0D%0A%0D%0AXXX To do:%0D%0A%22%22%22%0D%0A%0D%0Aimport csv%0D%0Aimport glob%0D%0Aimport re%0D%0Aimport sets%0D%0A%0D%0Aheadings = %5B%22Date%22, %22Time%22, %22Artist%22, %22Title%22%5D%0D%0Apat = re.compile('(?P%3CD%3E%5B0-9%5D%7B2%7D)/(?P%3CM%3E%5B0-9%5D%7B2%7D)/(?P%3CY%3E%5B0-9%5D%7B4%7D) (?P%3Ch%3E%5B0-9%5D%7B2%7D):(?P%3Cm%3E%5B0-9%5D%7B2%7D):(?P%3Cs%3E%5B0-9%5D%7B2%7D) SONG %22(?P%3Ca%3E%5B%5E-%22%5D+) - (?P%3Ct%3E%5B%5E%22%5D+)%22')%0D%0A%0D%0Adef make_row(m):%0D%0A    if m is None:%0D%0A        return None%0D%0A    d = m.groupdict()%0D%0A    return %5B%0D%0A        %22%25(Y)s-%25(M)s-%25(D)s%22 %25 d,%0D%0A        %22%25(h)s:%25(m)s:%25(s)s%22 %25 d,%0D%0A        d%5B'a'%5D,%0D%0A        d%5B't'%5D,%0D%0A    %5D%0D%0A%0D%0Adef fix(r):%0D%0A    if re.match('%5B0-9%5D+$', r%5B2%5D):%0D%0A        if ' _ ' in r%5B3%5D:%0D%0A            a, t = r%5B3%5D.split(' _ ', 1)%0D%0A        else:%0D%0A            no_title.add((r%5B2%5D, r%5B3%5D))%0D%0A            a, t = r%5B3%5D, '?'%0D%0A        r%5B2%5D = a%0D%0A        r%5B3%5D = t%0D%0A    return r%0D%0A%0D%0Ano_title = sets.Set()%0D%0Aall_data = %5B%5D%0D%0Afor fname in glob.glob('log*.txt'):%0D%0A    f = open(fname, 'r')%0D%0A    for line in f:%0D%0A        line = line.strip()%0D%0A        if not line:%0D%0A            continue%0D%0A        match = pat.match(line)%0D%0A        if not match:%0D%0A            continue%0D%0A        all_data.append(fix(make_row(match)))%0D%0A    f.close()%0D%0A    print 'Processed', fname%0D%0A%0D%0Aall_data.sort()%0D%0Ad1 = all_data%5B0%5D%5B0%5D.replace('-', '')%0D%0Ad2 = all_data%5B-1%5D%5B0%5D.replace('-', '')%0D%0Ag = open('log-%25s-%25s.csv' %25 (d1, d2), 'wb')%0D%0Aw = csv.writer(g, dialect='excel')%0D%0Aw.writerow(headings)%0D%0Aw.writerows(all_data)%0D%0Ag.close()%0D%0A%0D%0Ano_title = list(no_title)%0D%0Ano_title.sort()%0D%0Aif no_title:%0D%0A    print 'Tracks with no title (%25d)' %25 (len(no_title),)%0D%0A    for tpl in no_title:%0D%0A        print '%25s - %25s' %25 tpl%0D%0Aelse:%0D%0A    print 'No tracks found with no title.'%0D%0A%0D%0A%0D%0A

Convert RSPlayer 2 logs into CSV for programme return.