# Problem with get indice in file

**URL:** <https://forum.ansible.com/t/problem-with-get-indice-in-file/31076>\
**Category:** Ansible Project\
**Created:** [August 20, 2019, 12:39pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076 "2019-08-20T12:39:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 20, 2019, 12:39pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076/1 "2019-08-20T12:39:45Z")

</div>

Hey !

I have strange problem :

I have on file “clef\_applicatives.csv” with this content :

2,user1,host1,clef1  
7,user3,host2,clef5

6,user4,host4,clef6

42,user5,host5,clef7

23,user6,host8,clef8

3,user7,host3,clef9

22,user8,host10,clef14

20,user9,host7,clef11

I have on task who get indice depending on the host.

- set\_fact:  
indice: “{{ indice|default()|union(item.split(‘,’)[0]|list) }}”  
with\_lines: cat /home/ansible/ssh\_manager/clef\_applicatives.csv  
when: item.split(‘,’)[2] == inventory\_hostname  
delegate\_to: localhost

My problem is that this task works perfectly but when i use indice “22” in my file “clef\_applicatives.csv”, my variable indice get only 2 and not 22 same if my host is my inventory\_hostname …

Someone can help me please ??? 🙂

I’m desesper !!!

Thanks community ansible !!! 🙂

Regards,

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 20, 2019, 1:02pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076/2 "2019-08-20T13:02:30Z")

</div>

Hey,

Update.

The problem is that when i use number with same caractere exemple “11, 22, 33, 44, 55 , etc …”  
This task get only the first caracter “1 or 2 or 3 or 4 , etc…”

Thanks,  
Regards,

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 20, 2019, 1:29pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076/3 "2019-08-20T13:29:31Z")

</div>

Hi

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 20, 2019, 1:49pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076/4 "2019-08-20T13:49:47Z")

</div>

Hey,

This module not work !! 😕

I have error synthax i don’t understand why !! 😕

Can you help me for my first message please with this task :

- set\_fact:  
indice: “{{ indice|default()|union(item.split(‘,’)[0]|list) }}”  
with\_lines: cat /home/ansible/ssh\_manager/clef\_applicatives.csv  
when: item.split(‘,’)[2] == inventory\_hostname  
delegate\_to: localhost

Thanks you very much Community Ansible !!! 🙂

Regards,

---

<div class="post-metadata">

**Author:** ![Karther](https://avatars.discourse-cdn.com/v4/letter/k/3ec8ea/32.png) [@Karther](https://forum.ansible.com/u/Karther)\
**Post date:** [August 20, 2019, 2:32pm UTC](https://forum.ansible.com/t/problem-with-get-indice-in-file/31076/5 "2019-08-20T14:32:08Z")

</div>

Hey,

Help me please !!! 🙂

If i change this task with lookup, i will be to change my whole program !!! ;(

Regards,
