# Get item at index from list count

**URL:** <https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125>\
**Category:** Revit\
**Tags:** list-filter\
**Created:** [April 10, 2020, 8:25am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125 "2020-04-10T08:25:18Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 8:25am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/1 "2020-04-10T08:25:18Z")

</div>

Hello guys.  
I am working with a data set which is imported from excel.  
The data itself contains 9 rows of information that I am collecting my data from with the Get.ItemAtIndex.

So here I have 9 rows of data, and for each input I have to do the #9 so it does the collecting 9 times.  
But sometimes the data is 8,10,11,12 rows etc. So I thought I could use the list-count that automatically gets the number “9” and use as an input so the Dynamo Script is more automated than that the user has to change the number according to how many rows it is.

![list sorting](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c8587f9ad0a0b053743cc477e2fac034b26e1c7b.png)

Anybody got an idea?  
Regards, Joakim

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 8:50am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/2 "2020-04-10T08:50:11Z")

</div>

Hi @joakim.k97 ,

Is the number of columns for each row a fixed number ? or does it vary for each row ?

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 8:54am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/3 "2020-04-10T08:54:20Z")

</div>

It is the same, so the 0 and 8 in the code block is always their regardless of what is “#” is.

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 9:10am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/5 "2020-04-10T09:10:33Z")

</div>

[automate.py](https://forum.dynamobim.com/uploads/short-url/sBIWXoIa2cFrrnUBkv9lf29sZN6.py) (425 Bytes)

Just open it with any text editor and copy it to a Python script node

Does this serves the purpose ?

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 9:13am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/6 "2020-04-10T09:13:58Z")

</div>

Thank you, I will try.  
Should the “OUT” from the Python Scrip then be used as input for the “index” ast “List.GetItemAtIndex”?

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 9:16am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/7 "2020-04-10T09:16:16Z")

</div>

All items will be collected.  
for each row it will visit each column.You don’t have to use List.GetItemAtIndex.

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 9:18am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/8 "2020-04-10T09:18:44Z")

</div>

Yeah I see what you mean.  
But what I want to do is to start at 0, get that item, go 8 steps and collect that item, and then do that 9 times.  
Becuase now your code, just does exactly what the List.Flatten does, the output is the same.  
 ![flatten](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/464b0fac35bc1964a15ec44e73ed4093677a4cd0.png)

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 9:23am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/9 "2020-04-10T09:23:37Z")

</div>

So you just want to collect the 9th item , index 8 , only for each row ? right ?

Is it always the last item ?

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 9:33am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/10 "2020-04-10T09:33:18Z")

</div>

Maybe I explained myself wrong.  
I want to collect the item at “0”, then go 8 steps in the list and collect the next item, and then do that 9 times.  
So the output in the new list would be 0,8th,16th,24th,32th item etc.

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 9:46am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/11 "2020-04-10T09:46:22Z")

</div>

I think I got it.  
I hope this one works rightfully .

IN[0] dataList  
IN[1] step  
IN[2] repeatTimes

[a2.py](https://forum.dynamobim.com/uploads/short-url/wivw2G5TMsRVr5rmjzDlhfhESVP.py) (241 Bytes)

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 9:51am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/12 "2020-04-10T09:51:41Z")

</div>

Thank you Mohammad.  
That works good and now gives me the indexes 0,8,16 etc automatically from that list.

 ![works!](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c46ffe47de7314795632a37ed2e6ce08d1205141.png)

Then I want to expand it so I also can get 1,9,17 etc into a new list.  
I guess the script then just have to be modified with a “+1” to work then.

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 10:00am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/13 "2020-04-10T10:00:56Z")

</div>

You are welcome ! I am so glad that it worked

Here is this one , you can shift starting index to start at any index.

To start at index 1 shiftBy=1. to start at index 2 shiftBy =2 , and so on.

dataList= IN[0]  
step=IN[1]  
repeatTimes=IN[2]  
shiftBy=IN[3]

[a3.py](https://forum.dynamobim.com/uploads/short-url/pcepFC3lIOvtitvl6icUIaY6Eqe.py) (266 Bytes)

---

<div class="post-metadata">

**Author:** ![joakim.k97](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/joakim.k97/32/92961_2.png) [@joakim.k97](https://forum.dynamobim.com/u/joakim.k97)\
**Post date:** [April 10, 2020, 10:02am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/14 "2020-04-10T10:02:50Z")

</div>

Thank you very Much again, I had the idea that it should have been something like that. My Python skills are not so good but I am trying to learn.  
I wish you a happy easter and a nice weekend!

---

<div class="post-metadata">

**Author:** ![Mohammad\_Subani](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@Mohammad\_Subani](https://forum.dynamobim.com/u/Mohammad_Subani)\
**Post date:** [April 10, 2020, 10:09am UTC](https://forum.dynamobim.com/t/get-item-at-index-from-list-count/49125/15 "2020-04-10T10:09:28Z")

</div>

You are most welcome. 😌 😌

I wish you all the best.
