I have a txt file which contains 32000 lines. The data is in Arabo-Persian, however, each line contains the Roman transcription of the first word.
دێان diêyan بنووڕه دگان نگا دگان
دێان شكنه diêyan şêkêne دگان شكنه
دیدن dîdin بنووڕه دید نگا دید و تركیباتش
I need to put a comma before and after the Roman transcription. I have written this, but it puts a comma after every characters of the Roman transcription:
import re
output = open("output.txt","w")
input = open("sample.txt").read()
for word in input:
output.write(re.sub(r'^([a-z])', r',\1', word))
output.close()
Any suggestions?