Documentation > CMS Template API Library > Util > CreateListFromCsv(String,Char)

CreateListFromCsv

Converts CSV file contents into a List of Dictionaries. Requires the first line in the data to be column headers.

public List<Dictionary`2> CreateListFromCsv(String,Char)


Returns

A list of dictionaries. Each dictionary represents a row in the csv.

Parameters

NameDescriptionType
csvData CSV data with column headers on first line System.String
separator Optional: The character to delimit the data. Defaults to , System.Char

Code Example

C#

Sample:

            		
            <%
            List<Dictionary<string,string>> list = Util.CreateListFromCsv(testText, ',');
            foreach(Dictionary<string, string> dictionary in list)
            {
              string data = dictionary["colName1"];
            }
            %>
            
            	

Connect with Crownpeak