Hi Vladimir ,
I got it by using the join - s1_34: "{{ [[1], [3, 4]]| map('map',
'extract', arr)| join(',')}
On Sunday, October 15, 2023 at 1:08:39 AM UTC+5:30 Vladimir Botka wrote:
> On Sat, 14 Oct 2023 10:32:51 -0700 (PDT)
> Veera wrote:
>
> > Is there a way to combine the 2 positional v
On Sat, 14 Oct 2023 10:32:51 -0700 (PDT)
Veera wrote:
> Is there a way to combine the 2 positional values ...
> to print like below
> - two
> - four five
Split the string and trim the items
arr: "{{ myline|split(',')|map('trim') }}"
gives
arr:
- This line is a test
- two
- thr
Hi Todd,
Is there a way to combine the 2 positional values .
"{{ [2, 4, 5] | map('extract', myline.split(',')) }}"
as
"{{ [2, 4 5] | map('extract', myline.split(',')) }}"
to print like below
- two
- four five
I tried to combine .. but missing a bit
"{{ [2, combine [4 5] | map('extr
Thanks Todd.
I got the desired output and it answers the other thread also .
https://groups.google.com/g/ansible-project/c/ZqZuw3do-5g/m/hMlDvLceAQAJ
(Now I understand it is a string.. )
On Tuesday, August 29, 2023 at 5:24:04 PM UTC+5:30 Todd Lewis wrote:
> You have 6 delimiters, so o
You have 6 delimiters, so only 7 fields. Your maximum index therefore is 6.
Setting that issue aside, you can use map(), like so:
"{{ [2, 4, 5] | map('extract', myline.split(',')) }}"
Cheers,
--
Todd
On 8/29/23 3:40 AM, Veera wrote:
Hi,
I have this playbook to print the columns 5 and 6
> Do split accepts only one square bracket[] parameter?
the python aquivalent (something similar to this should be happening in the
backgound) would be:
>>> myline = 'This line is a test, two, three, four, five, 6, seven'
>>> print(myline.split(',')[4], myline.split(',')[5], myline.split
Hi,
I have this playbook to print the columns 5 and 6 using the debug.
---
- name: playbook to print columns
hosts: localhost
gather_facts: no
vars:
myline: This line is a test, two, three, four, five, 6, seven
tasks:
- name: play to print
debug:
msg:
-