Reformatting a table

Is there a convenient way to reformat, for instance, a 1x50 table into a 5x10 table?

I’m taking in OSC data for an arbitrary number of tracked objects, all of which come in together in a single string. Each object has five attributes/values, but the input string has no delimiters. So a string with 50 values represents 10 tracks and looks like, for instance:
1 3.988 2.123 5.725 1.000 2 5.152 7.152 9.028 1.000 etc

I can parse the string into a table using a CHOPto DAT, but it’s just 50 columns and one row.
How can I reformat a table by splitting every N cells into a new row?

I’m looking into parsing the raw OSC data in Python, but it would be really nice to do this all with nodes. Ultimately I need to be able to send a table out to a replicator, so I can have each tracked object (however many there happen to be at a given moment) represented on screen.

Thanks!

UPDATE:
I would still love to be able to do this as nodes, but in the mean time, here’s the python script I’m using. I have no idea whether or not I’m being terribly inefficient, but this is running inside an Execute DAT. It reads in values from an OSCIn DAT, and writes out values to a Text DAT. The Text DAT then feeds into a Convert DAT, which in turn drives my Replicator Comp:

FEILDS_PER_TRACK = 5

def processRow(ls, start):
	table = ""
	i = start
	while(i < len(ls) and ls[i][0] != '/'):
		row = ""
		for j in range(FEILDS_PER_TRACK):
			row += " " + ls[i+j]
		table += row + "\n"
		i += FEILDS_PER_TRACK
	return table, i
		

def processLine(ln):
	ls = ln.split()
	#print(ls)
	minX = ls[2]
	maxX = ls[3]
	minZ = ls[4]
	maxZ = ls[5]
	curIndex = 7 # start after /tracks
	tracks, curIndex = processRow(ls, curIndex)
	enters, curIndex = processRow(ls, curIndex+1)
	exits, curIndex = processRow(ls, curIndex+1)
	return [minX, maxX, minZ, maxZ], tracks, enters, exits


def frameStart(frame):
	oscDat = op('oscin2')
	while(oscDat.numRows > 0):
		#print(oscDat[0,0].val)
		dims, tracks, enters, exits = processLine(oscDat[0,0].val)
		#print(tracks)
		oscDat.deleteRow(0)
		#return(tracks)
		op('tracksText').clear()
		op('tracksText').write(tracks)

Feel free to point out any fatal mistake or faux pas.

Thanks,
–David

An approach involving CHOPs might work:

  • convert the dat with the 50 columns into a CHOP via the DATto CHOP
  • now add a Shuffle CHOP to the output of the DAtto CHOP and use the method “Split N Samples”
  • set the N parameter to the number of values you need per channel
  • now you can convert it back to a DAT with the CHOPto DAT

would that work?
cheers
Markus

AAAAAAaaaaaahahahahaa oh man, that’s exactly what I needed.
And I only lost three hours learning to use Python (but that’s a good thing to have done anyway).

I have one more question now that I’ve come this far, but I’ll start a new post for it.

Thanks, Markus