csv_to_list

Overview

Converts a CSV to a list of dictionaries. The dictionary’s keys are read from the header of the CSV.

Parameters

  • csvstring – A CSV in a string. Note that this CSV must include headers for this tag to work properly.

Example

{% csv_to_list csv_string %}
Example Input:

contents of csv_string:

Year,Make,Model,Mileage
2007,Toyota,Corolloa,128635
2015,Honda,Odyssey,42331
2018,Tesla,S,12011
Example Output
[{'Make': 'Toyota', 'Mileage': '128635', 'Model': 'Corolloa', 'Year': '2007'},
 {'Make': 'Honda', 'Mileage': '42331', 'Model': 'Odyssey', 'Year': '2015'},
 {'Make': 'Tesla', 'Mileage': '12011', 'Model': 'S', 'Year': '2018'}]