for line in source_file:
    first_part = line.split('|')[0]
if first_part in my_id_strs:
    target_file.write(line.replace(',', ';').replace('|', ','))
Fastest check if line starts with value in list?