-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNormalStream.py
39 lines (27 loc) · 997 Bytes
/
NormalStream.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 threading
import time
import SqsProducerKombu
# Producer Thread Class
msg_no = 0
combined_message_count = 1
msg_consumed= 0
combined_message = ""
start_time = time.time()
import codecs
try:
#using codecs to handle to non-unicode symbols in the file
with codecs.open(r"C:\Users\sunit\Desktop\CapstoneProject\data\nearby-all-public-posts\salesData.csv",'r',encoding ='utf-8') as csv_file:
for line in csv_file:
print(f'published_message{line}')
msg_no += 1
combined_message += line
if msg_no >= combined_message_count:
#send_message to the messaging service
SqsProducerKombu.send_message_SQS(combined_message)
print(f'consumed message:{combined_message},{msg_consumed}')
combined_message = ""
msg_no = 0
msg_consumed += 1
except Exception as e:
print(e)
print(time.time() - start_time)