# Ansible dict date to csv file

**URL:** <https://forum.ansible.com/t/ansible-dict-date-to-csv-file/37082>\
**Category:** Ansible Project\
**Created:** [September 10, 2022, 4:44pm UTC](https://forum.ansible.com/t/ansible-dict-date-to-csv-file/37082 "2022-09-10T16:44:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sagan](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sagan](https://forum.ansible.com/u/Sagan)\
**Post date:** [September 10, 2022, 4:44pm UTC](https://forum.ansible.com/t/ansible-dict-date-to-csv-file/37082/1 "2022-09-10T16:44:02Z")

</div>

IF you have your closters has dicts in your variable you can use a loop with dict2items and loop around it, as to writing it in your file you can use this module

[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html)

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [September 10, 2022, 4:49pm UTC](https://forum.ansible.com/t/ansible-dict-date-to-csv-file/37082/2 "2022-09-10T16:49:25Z")

</div>

> IF you have your closters has dicts in your variable you can use a loop with dict2items and loop around it, as to writing it in your file you can use this module  
> [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html)

Using lineinfile doesn't make sense when your write the whole file. In this case the template module is the better choice.

Regards

```
          Racke

```
