def panproducer(name): q = que.Que() # df = pd.DataFrame(columns=['userID','movieID','rating','date_day','date_month','date_year','date_hour','date_minute','date_second']) # f = open('/home/przemysaw/PycharmProjects/wtiproj01/user_ratedmovies.dat',"r") df = pd.read_csv( '/home/przemysaw/PycharmProjects/wtiproj01/user_ratedmovies.dat', sep=" ", header=None, nrows=100, delimiter="\t", names=[ 'userID', 'movieID', 'rating', 'date_day', 'date_month', 'date_year', 'date_hour', 'date_minute', 'date_second' ]) # f1 = f.readlines() # i=0 # for x in f1: # if i <1000: # l = x.split() # df = df.append({'userID':l[0],'movieID':l[1],'rating':l[2],'date_day':l[3],'date_month':l[4],'date_year':l[5],'date_hour':l[6],'date_minute':l[7],'date_second':l[8]},ignore_index=True) # i+=1 # # for row in df.to_dict(orient='record'): # # js = json.dumps(row) # # q.put(name,js) # # <--Alternatywa metoda do iterrows --> for index, row in df.iterrows(): print(row) js = json.dumps(row.to_dict()) q.put(name, js) time.sleep(1.00 / 4)
def producer(name): i = 0 q = que.Que() while i < 1000: fjson = fakejson.fakeJson() js = json.dumps(fjson) q.put(name, js) i += 1 time.sleep(0.01)
def consumer_1(name): redis = que.Que() if not redis.exists(name): print('wrong key') else: records = redis.get_all(name) for x in records: print(json.loads(x.decode('utf-8'))) time.sleep(1.00)
def consumer(name): q = que.Que() while True: s = q.get(name) if s is None: time.sleep(1.00) s = q.get(name) if s is None: print('komunikacja zakonczona') break else: h = json.loads(s.decode('utf-8')) print(h) time.sleep(1.0 / 4)
def consumer_2(name): redis = que.Que() print(redis.rpop(name)) if not redis.exists(name): print('wrong key') else: records = redis.get_all(name) end = time.time() + 10 while time.time() < end: for x in records: if x is None: print('no data to display') else: print(json.loads(x.decode('utf-8'))) time.sleep(1.00 / 4)
def producer_2(name): redis = que.Que() df = p.read_csv('../data/user_ratedmovies.dat', sep=" ", header=None, nrows=100, delimiter="\t", names=[ 'userID', 'movieID', 'rating', 'date_day', 'date_month', 'date_year', 'date_hour', 'date_minute', 'date_second' ]) for index, row in df.iterrows(): print(row) js = json.dumps(row.to_dict()) redis.lpush(name, js) time.sleep(1.00 / 4)
import que q = que.Que() q.enque_file("test.txt") q.start_que_runner()
def fai_ip(self, position): x = que.Que().start(que.get_ip_list(position)) # print(x) return x