Here i want to indivually seprate datas like calc dir, mode,desire angle, actual pos. and run script such way that when it get executed data suppose to be written into paricular column without overlap. can some tell me modify code above

with open("time.txt", "a+") as wfh: writer = csv.writer(wfh) for i in xrange(5): result = ser.read(150) writer.write(result.split(':'))

ser.close()

You might wanna clean your values by removing the '\r\n' before you write them, etc; but that's the general idea. The key is to use a csv.writer and pass it a list containing the individual field values, rather than attempting to write the string you get from serial to file directly.