<jupyter_start><jupyter_text>TCP Client<jupyter_code>df.to_csv("fish_waveform_01.csv", header=False)
import socket
import sys
import math

data_interval = mat_contents["Tinterval"][0,0]
data = mat_contents['A']
index = 0

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("127.0.0.1", 12345))

last_time = time.time()
while True:
    interval = last_time - time.time() 
    index = math.ceil(index + interval / data_interval) % len(data) # Takes into account the time gap
    message = f"{data[index,0]}".encode()
    sock.send(message)
    last_time = time.time() # Note that we get a new time here, in case the interval is so small the code 
#     time.sleep(0.001)

sock.close()
import time
time.time()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13188220230473752, 'fraction_numerical': 0.026888604353393086, 'mean_word_length': 4.666666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '173323', 'license': 'MIT', 'n_tokens_mistral': 289, 'n_tokens_neox': 276, 'n_words': 69, 'path': 'results/Play recording.ipynb', 'repo_name': 'altear/MeanFishTime', 'size': '781'}