-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.py
More file actions
36 lines (31 loc) · 1.34 KB
/
Client.py
File metadata and controls
36 lines (31 loc) · 1.34 KB
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
import pickle
import asyncio
import websockets
import pandas as pd
async def PCT_pointcloud_loader():
uri = "ws://localhost:8765"
async with websockets.connect(uri) as websocket:
pointcloud_array = []
with open(r'Path to the file',newline='') as pointcloud_csv_file:
import csv
try:
reader = csv.reader(pointcloud_csv_file)
for row in reader:
pointcloud_array.append((row))
except IOError:
print("Could not read file:", pointcloud_csv_file)
pointcloud_serialized = pickle.dumps(pointcloud_array)
await websocket.send(pointcloud_serialized)
print(f'Point cloud data Sent to server')
######################
#Data sent to server
######################
processed_pointcloud_serialized= await websocket.recv()
processed_pointcloud_array = pickle.loads(processed_pointcloud_serialized)
processed_pointcloud_array_dataframe = pd.DataFrame(processed_pointcloud_array)
try:
processed_pointcloud_array_dataframe.to_csv("Predicted_pointcloud.csv", index=False)
print(f"< Whole process is done")
except:
print("Something went wrong, couldn't write the file")
asyncio.get_event_loop().run_until_complete(PCT_pointcloud_loader())