Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:15
What would you like to do?
Cats a file to a tcp endpoint line by line using streams and zeromq
import zmq
import io
import time
import sys
import re
# reads line by line a file and sends it
# to a tcp endpoint using zeromq
# handy to cat big files to a listener
context = zmq.Context()
socket = context.socket(zmq.PUB)
fileName = sys.argv[1]
with, 'r') as file:
l = file.readline()
while True and l !='':
l1 = l.replace('"','')
l2 = re.sub(r'\\t',' ', l1)
l3 = re.sub(r'\\n', '', l2)
#print l3.rstrip('\n')
l = file.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment