current data
NUM |FIRSTNAME| SURNAME |course |
------------------------------------------
12400 ERIC RONNEY CS
------------------------------------------
12500 MICHAEL OWEN CS
------------------------------------------
12600 SCOT MAN CS
------------------------------------------
12700 GEOGE YO IT
------------------------------------------
Code:
import re
returnline = []
f = open("List.txt", "r")
for line in f.readlines():
returnline.append(re.compile(' ').sub(',', line[0:-1]))
for item in returnline:
print item
new data after the program is excutered
Code:
NUM,,,|FIRSTNAME|,SURNAME,|course,|
NUM,,,|FIRSTNAME|,SURNAMENAME,|course,|
------------------------------------------
NUM,,,|FIRSTNAME|,SECONDNAME,|course,|
------------------------------------------
12400 ERIC ROONEY CS
NUM,,,|FIRSTNAME|,SURNAME,|course,|
------------------------------------------
12400 ERIC ROONEY CS
------------------------------------------
NUM,,,|FIRSTNAME|,SURNAME,|course,|
------------------------------------------
12400 ERIC ROONEY CS
------------------------------------------
12500 MICHAEL OWEN CS
NUM,,,|FIRSTNAME|,SURNAME,|course,|
------------------------------------------
and the program just rans forever and it dont stop