Dear all,
I am reading data from Serial port. data are in format below. Below code are seprating the data. I wanna know how can write it in excel sheet with time and date/mode/ dir/ actual postion as header and values which are CSV under paricular header
----------
time and date: 23-3-13 3:14:23
mode:1
dir:fw
actual pos:30
desired pos:28
------
I am reading data from Serial port. data are in format below. Below code are seprating the data. I wanna know how can write it in excel sheet with time and date/mode/ dir/ actual postion as header and values which are CSV under paricular header
----------
time and date: 23-3-13 3:14:23
mode:1
dir:fw
actual pos:30
desired pos:28
------
import serial import csv import os import time def main(): pass if __name__ == '__main__': main() COUNT=0 while(COUNT<=2): ser=serial.Serial() ser.port=12 ser.baudrate=9600 ser.open() str=ser.read(150) val=str.split(":") print "value is",val lines=str.split("\r\n") ser.close() COUNT=COUNT+1 for lines in lines[:-1]: parts=lines.split(":") foo=open("new.txt","a+"); foo.write("%s," % ":".join(parts[1:])) print parts[1:] foo.write("\n") foo.close()