for row in r:
    row[-1] = row[-1].replace('S-D', 'S')
new_data.append(row)
newfilename = ''.join(filename.split('.csv')) + '_edited.csv'
with open(newfilename, 'w') as f:
    writer = csv.writer(f)
writer.writerows(new_data)
Пакетное редактирование CSV-файлов с помощью Python