Sending converted bytes to a table

I am ingesting ASCII data via a UDP In DAT and using python code to convert the bytes into floats, as outlined in this informative thread.

Using code @rob mentioned in one of their responses, the code is:

def onReceive(dat, rowIndex, message, bytes, peer):
unpacked_data = struct.unpack(‘ffffffffffffffffffffff’, bytes)
return

This returns a series of floats, for example:

(2.9002795720600716e-09, 2.0356152057647705, -346.42205810546875, 0.30921635031700134, 0.0002073488722089678, -0.00017349699919577688, -0.00023823404626455158, -0.003812377341091633…)

Ultimately I’d like to have each float exist in an individual cell of a Table DAT. I’m just wondering what the most efficient way to do that is.

I tried sending the converted text to a Text DAT via op(‘text1’).write(unpacked_data) but then my computer started to explode because that just kept appending the text to the end of each instance. This data is being streamed from a motion platform and I really only need present values.

I appreciate any suggestions!

Have you tried DAT.appendRows? If you have your floats in a list/tuple you should just be able to provide that as the vals argument.

Yup, that works. Kinda of a “duh” moment because appendRow (singular) has been a go to for a while. I first piped the data into a regular table DAT, and that was fun to see how many cells I was generating.

Replacing that with a FIFO DAT did the trick. Thank you!

1 Like