-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublisher.py
39 lines (32 loc) · 878 Bytes
/
publisher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import zmq
import time
import sys
import pandas as pd
from re import search
from pandaszmq import send_dataframe
def file_slice(file_name):
file = open(file_name, "r")
file_len = 0
idx = 0
found = False
Content = file.read()
CoList = Content.split("\n")
for i in CoList:
if i:
file_len += 1
if search(']', i) and (not found):
found = True
idx = file_len
file.close()
return idx, file_len
port = "9090"
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:%s" % port)
idx, file_len = file_slice("RadarData\Radar0.txt")
df = pd.read_table("RadarData\Radar0.txt", skiprows=6, skipfooter=file_len -
idx, delim_whitespace=True, engine='python', header=None)
while True:
send_dataframe(socket=socket, obj=df)
print(df)
time.sleep(1)