How to pull the numbers in-between numbers given

Here's what I'm trying to accomplish inside of my tag creator screen.

I have a table and I would like to enter 2 different values in the same row, col ie. (1,8).
Do we have a way of pulling out the numbers 1 thru 8 ? If only 1 and 8 are presented to the dataset?
Also note, i would like to retain the 8 so that in the row below if they put 1 thru 5, we would know to start at 9 thru 13.
If not, does anyone know a way to do this outside of a dataset using numeric text field ?
Any help would be greatly appreciated !

What do you want to do with these numbers ?
Do you want to create new row in the dataset ?

range(x, y+1) will generate all the numbers from x to y BOTH included

1 Like

These numbers will run through my tag creator and produce tags from the range(1,8) using the numbers at the end of the tag ex. TT[1], TT[2] all the way up to 8.

What does datasets have to do with this ?
Is that just the one in the table's data property ?
Is there anything else in your table ?
is the number of numeric entry fields dynamic ?
Is the base tag path always the same ?
Do you want the numbers to start from 1 or from the first value entered ?

This raises so many questions !

something like this maybe ?

ranges = zip(ds.getColumnAsList(index_of_start_column), ds.getColumnAsList(index_of_end_column))
r = reduce(lambda x, (s, e): x + (e - s), ranges, 0)
paths = [base_path.format(n) for n in xrange(1, r)]

I think you should give us an example, to make things clear.
Let's say user inputs something like this:

1, 8
3, 6
2, 7

What's the list of numbers you expect from that ?
What happens if someone enter let's say 5, 2 ?

1 Like

What does "pull the numbers" mean? It's not a programming term - is it?


Here's a picture of what I have on the screen.
My Op tagpath is as follows opIndex = 'Op[' +[1][o] + ']' which spits out Op[1] tagpath.
I would like to do the same for my TT[1] thru TT[8] with what's entered in the TT section. My Op[1] could potentially have 8 TTs in one Op. I'm not sure what way is easiest to accomplish this.

I'm sorry but this is really, REALLY not clear.
Let's say you have this table:

OP Name Array TT
Op5 1 2,8
Op6 2 3, 4
Op7 3 2, 5

What's the EXACT list of paths you want to get from that ?

1 Like

My apologies , all I want to take from the table you have would be this:
2,8 = TT[1], TT[2],TT[3],TT[4],TT[5],TT[6],TT[7]
3,4 = TT[8], TT[9]
2,5 = TT[10], TT[11], TT[12] , TT[13]
TT[x ] is my tagpath which is also an array.

You really need to take a step back, read out-loud what you have written in each of your posts, and ask yourself how is anyone to understand it.

According to your last post,

  • 2,8 infers TT[1] to TT[7], excluding 8 but including 2!
  • 3,4 infers TT[8] and TT[9]. What have 3 and 4 got to do with it?
  • 2,5? How does that relate to the four values that follow?

That is: What you're saying likely makes perfect sense in your head, but we're all not familiar enough with your environment/requirements/previous attempts/all other context to piece it together.

So to avoid the XY problem, try to, as clearly as possible, describe what it is you're trying to do with all the context you can. This forum's full of volunteers who are more than willing to help, but no one likes working with unclear requirements.


I'm gonna assume the "x,y" in the TT column actually a string. This should build a list of paths that look like ["TT[1]", ..., "TT[n]"]

ranges = ((int(n) for n in r.split(',')) for r in ds.getColumnAsList(2))
r = reduce(lambda x, (s, e): x + (e+1 - s), ranges, 1)
paths = ["TT[{}]".format(n) for n in xrange(1, r)]
1 Like

Shouldn't it be this:

2,8 = TT[0], TT[1],TT[2],TT[3],TT[4],TT[5],TT[6]
3,4 = TT[7], TT[8]
2,5 = TT[9], TT[10], TT[11] , TT[12]

Why would TT[0] be skipped?

1 Like

You're correct however for this project the customer considers 0 as Null and is not used in this project.

You still have given no explanation of what you are trying to achieve or what those number patterns mean.

He's trying to pull the numbers. :slight_smile:

I think he needs to generate tags paths. The pattern then is irrelevant, as it could be anything whoever is in charge has decided. Start with 0, start with 1, start with 3, skip even numbers... doesn't really matter at this point.

1 Like