Remove line breaks
Posted: Tue Aug 19, 2014 9:35 pm
All,
My script for creating a file is including line break from a script I can't figure out how to edit. I am trying to create a CSV file, and while the commas appear in the correct places, I can't seem to rid the final result of the \n lines.
Is there a way to remove the line breaks after the file has been created? Portion of script in questions below:
My script for creating a file is including line break from a script I can't figure out how to edit. I am trying to create a CSV file, and while the commas appear in the correct places, I can't seem to rid the final result of the \n lines.
Is there a way to remove the line breaks after the file has been created? Portion of script in questions below:
Code: Select all
import serial
ser = serial.Serial('/dev/ttyUSB0', 57600, timeout=100)
print ser.name
finaltags = open (gpsfile, 'a')
i = 0
while i < 50:
x = ser.read(1) # read one byte
s = ser.read(10) # read up to ten bytes (timeout)
back = ('\b')
print ser.readline() # read a '\n' terminated line
finaltags.write(ser.readline())
finaltags.write(space)
i = i + 1
finaltags.close()