In RDS data there is no preamble, finding RDS groups can be achieved by using checkword (+offset).

rdspi.jpg

block_offsets = (0b0011111100, 0b0110011000, 0b0101101000, 0b0110110100)
groups = ('A', 'B', 'C', 'D')

def calc_cw(bits, offset):
    x = (119, 743, 943, 779, 857, 880, 440, 220, 110, 55, 711, 959, 771, 861, 882, 441)
    crc = 0
    for i in range(len(bits)):
        if bits[i] == '1':
            crc ^= x[i]
    return crc ^ block_offsets[offset]

pi = '0110001000000011' # 0x6203 = YLE Radio Suomi
data = ""
f = open('rds-out.txt', 'r')
line = f.readline().strip()
while line != "":
    data += line
    line = f.readline().strip()
f.close()
l = len(data)
payload = ""
checkword = ""
p = 0
name = ""
blocks_found = 0
while p <= l:
    payload = data[p:p+16]
    checkword = data[p+16:p+16+10]
    if ((len(payload)) + (len(checkword)) == 26):
        for i in range(len(groups)):
            cw = calc_cw(payload, i)
            if (cw == int(checkword, 2)) == True:
                name = ""
                if payload == pi:
                    name = 'YLE Radio Suomi'
                print groups[i], payload, bin(cw)[2:].zfill(10), name
                blocks_found += 1
                break
    if blocks_found > 8:
        break
    p += 1