I want to replace all of the empty characters with single empty character. I tried this:
import re
fin = open("toutput_des.txt", "r")
fout = open("toutput2_des.txt", "w")
for line in fin:
fout.write(re.sub('\s+',' ',line))
fin.close()
fout.close()
It worked but it also replaced "new line" character at the end of each line with a single empty character. If I want to exclude the "new line" how can I modify regex? I also tried '\s+\b' but it deleted all of the contents of the file.