py-serial + CSV

McBooCzech petr at
Tue Aug 23 20:00:32 CEST 2005

Sorry, I did not mentioned the data flow from the serial port is
permanent/continuous (as long as the GPS receiver is connected to the
serial port). The input data are commning every second, they are comma
separated and they are looking like:


>From the rows they are begining with $GPRMC I want to get following
data only (positions 2,4,6)

This (according to your suggestions) is my code which works for me

import serial
s = serial.Serial(port=0,baudrate=4800, timeout=20)
while 1:
	line = s.readline()
	words = line.split(',')
	if words[0]=="$GPRMC":
		print words[1], words[3], words[5]

I just wonder if there is some beter (or as you are saying "more
pythonic":) aproach how to write such a piece of code.
Petr Jakes

More information about the Python-list mailing list