I always work on Arabic text files and to avoid problems with encoding I transliterate Arabic characters into English according to Buckwalter\'s scheme (http://www.qamus.org/tra
You're redoing the same work for every character. When you do data = data.replace(k, v)
, that replaces all occurrences of the given character in the entire file. But you do this over and over in a loop, when you only need to do it once for each transliteration pair. Just remove your outermost loop and it should speed your code up immensely.
If you need to optimize it more you could look at the string translate method. I'm not sure how that is performance-wise.