community / community.general / 3.8.10 / filter / from_csv Converts CSV text input into list of dicts | "added in version" 2.3.0 of community.general" Authors: Andrew Pantuso (@Ajpantuso)community.general.from_csv (3.8.10) — filter
Install with ansible-galaxy collection install community.general:==3.8.10
collections: - name: community.general version: 3.8.10
Converts CSV text input into list of dictionaries.
- name: Parse a CSV file's contents ansible.builtin.debug: msg: >- {{ csv_data | community.genera.from_csv(dialect='unix') }} vars: csv_data: | Column 1,Value foo,23 bar,42
_input: description: A string containing a CSV document. required: true type: string strict: description: - Whether to raise an exception on bad CSV input. - When using this parameter, you change the default value used by I(dialect). - The default value depends on the dialect used. type: bool dialect: default: excel description: - The CSV dialect to use when parsing the CSV file. - Possible values include C(excel), C(excel-tab) or C(unix). type: str delimiter: description: - A one-character string used to separate fields. - When using this parameter, you change the default value used by I(dialect). - The default value depends on the dialect used. type: str fieldnames: description: - A list of field names for every column. - This is needed if the CSV does not have a header. elements: str type: list skipinitialspace: description: - Whether to ignore any whitespaces immediately following the delimiter. - When using this parameter, you change the default value used by I(dialect). - The default value depends on the dialect used. type: bool
_value: description: A list with one dictionary per row. elements: dictionary type: list