# How to pull the numbers in-between numbers given

**URL:** <https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [September 21, 2023, 1:55pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451 "2023-09-21T13:55:53Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![CJ\_Lake](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CJ\_Lake](https://forum.inductiveautomation.com/u/CJ_Lake)\
**Post date:** [September 21, 2023, 1:55pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/1 "2023-09-21T13:55:53Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2023, 2:00pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/2 "2023-09-21T14:00:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CJ\_Lake](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CJ\_Lake](https://forum.inductiveautomation.com/u/CJ_Lake)\
**Post date:** [September 21, 2023, 2:04pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/3 "2023-09-21T14:04:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2023, 2:16pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/4 "2023-09-21T14:16:19Z")

</div>

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 ?

```python
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)]

```

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

```auto
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` ?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 2:19pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/5 "2023-09-21T14:19:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CJ\_Lake](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CJ\_Lake](https://forum.inductiveautomation.com/u/CJ_Lake)\
**Post date:** [September 21, 2023, 2:37pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/6 "2023-09-21T14:37:01Z")

</div>

![Capture](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/d/8d95f86257e5834e99d5f241689b1a062c071168.jpeg)

Here's a picture of what I have on the screen.  
My Op tagpath is as follows opIndex = 'Op[' + opsData.data[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.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2023, 2:43pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/7 "2023-09-21T14:43:00Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![CJ\_Lake](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CJ\_Lake](https://forum.inductiveautomation.com/u/CJ_Lake)\
**Post date:** [September 21, 2023, 2:54pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/8 "2023-09-21T14:54:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 2:57pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/9 "2023-09-21T14:57:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 21, 2023, 3:01pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/10 "2023-09-21T15:01:44Z")

</div>

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](https://en.wikipedia.org/wiki/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.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 21, 2023, 3:03pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/11 "2023-09-21T15:03:33Z")

</div>

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]"]`

```python
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)]

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [September 21, 2023, 5:04pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/12 "2023-09-21T17:04:53Z")

</div>

Shouldn't it be this:

```auto
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?

---

<div class="post-metadata">

**Author:** ![CJ\_Lake](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@CJ\_Lake](https://forum.inductiveautomation.com/u/CJ_Lake)\
**Post date:** [September 22, 2023, 1:16pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/13 "2023-09-22T13:16:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 24, 2023, 9:47pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/14 "2023-09-24T21:47:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 24, 2023, 10:48pm UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/15 "2023-09-24T22:48:44Z")

</div>

He's trying to pull the numbers. 🙂

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 25, 2023, 7:01am UTC](https://forum.inductiveautomation.com/t/how-to-pull-the-numbers-in-between-numbers-given/79451/16 "2023-09-25T07:01:10Z")

</div>

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.
