Note
This filter plugin is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.from_csv.
New in community.general 2.3.0
This describes the input of the filter, the value before | community.general.from_csv.
Parameter | Comments |
|---|---|
Input string / required | A string containing a CSV document. |
This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | community.general.from_csv(key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
delimiter string | A one-character string used to separate fields. When using this parameter, you change the default value used by The default value depends on the dialect used. |
dialect string | The CSV dialect to use when parsing the CSV file. Possible values include Default: |
fieldnames list / elements=string | A list of field names for every column. This is needed if the CSV does not have a header. |
skipinitialspace boolean | Whether to ignore any whitespaces immediately following the delimiter. When using this parameter, you change the default value used by The default value depends on the dialect used. Choices:
|
strict boolean | Whether to raise an exception on bad CSV input. When using this parameter, you change the default value used by The default value depends on the dialect used. Choices:
|
- name: Parse a CSV file's contents
ansible.builtin.debug:
msg: >-
{{ csv_data | community.general.from_csv(dialect='unix') }}
vars:
csv_data: |
Column 1,Value
foo,23
bar,42
# Produces the following list of dictionaries:
# {
# "Column 1": "foo",
# "Value": "23",
# },
# {
# "Column 1": "bar",
# "Value": "42",
# }
Key | Description |
|---|---|
Return value list / elements=dictionary | A list with one dictionary per row. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/from_csv_filter.html