I am collecting/receiving data of received signal continuously in real time and receiving through the zmq pull and then saving it in csv format. The received data is in numeric values of presence of peak signal. whenever i got peak there is peak value otherwise value is zero.
Now this data is coming in sets. i want to save this data in csv continuousy in column row by row and after 70k sample data, the data will move to next column and so on.
import pandas as pd
import time
import zmq
import random
import numpy as np
import matplotlib.pyplot as plt
import csv
coldata = []
def consumer():
context = zmq.Context()
consumer_receiver = context.socket(zmq.PULL)
consumer_receiver.connect("tcp://127.0.0.1:5557")
while True:
buff = consumer_receiver.recv()
received_data = np.frombuffer(buff, dtype="float32", count=-1, offset=0)
realdata = pd.DataFrame([received_data])
coldata = realdata.T
print(len(data))
for i in range(5):
coldata.loc[i] = list(data(size=70000))
coldata.to_csv("dataframed samples008.csv", mode ='a')
print(coldata)
## here i was trying to wite and then by reading trying to manipulate
## but i'm very new to pandas and dont know how to do it
with open("csv00030.csv","a",newline='') as f:
sample_data = csv.writer(f)
sample_data.writerow(data)
with open("csv00030.csv","r",newline='') as file:
csvFile = csv.reader(file)
for samples in csvFile:
print(samples)
# write 70k samples data in each row or column
#
consumer()