I finally wrote a program to recieve data from a socket:
from socket import *
HOST = 'localhost'
PORT = 30003 #our port from before
ADDR = (HOST,PORT)
BUFSIZE = 4096
sock = socket( AF_INET,SOCK_STREAM)
sock.connect((ADDR))
def readlines(sock, recv_buffer=4096, delim='\n'):
buffer = ''
data = True
while data:
data = sock.recv(recv_buffer)
buffer += data
while buffer.find(delim) != -1:
line, buffer = buffer.split('\n', 1)
yield line
return
for line in readlines(sock):
print line
I am recieving the required data line by line but there is a new line character at the end of each line which is not required for me.
Please tell me how to remove the character at the end of each line. I want to save these data to a database,line by line, in CSV format.
Regards
Manoj