CSV Reports
CsvStringToDictionary Method
Example 



KellermanSoftware.CsvReports Namespace > CsvReader Class : CsvStringToDictionary Method
A CSV String with a header
Read a CSV String and return a dictionary with the keys as the header names. By default header column name spaces are removed. See RemoveColumnNameSpaces.
Syntax
Public Function CsvStringToDictionary( _
   ByVal csvString As String _
) As List(Of Dictionary(Of String,String))
Dim instance As CsvReader
Dim csvString As String
Dim value As List(Of Dictionary(Of String,String))
 
value = instance.CsvStringToDictionary(csvString)
public List<Dictionary<string,string>> CsvStringToDictionary( 
   string csvString
)
public:
List<Dictionary<String^,String^>^>^ CsvStringToDictionary( 
   String^ csvString
) 

Parameters

csvString
A CSV String with a header

Return Value

A dictionary list
Example
CsvReader csvReader = new CsvReader(); //Trial Mode
//CsvReader csvReader = new CsvReader("place user name here", "place license key here"); //License Mode            
 
string csvString = "FirstName,LastName\r\nJohn,Smith";
 
List<Dictionary<string,string>> results = csvReader.CsvStringToDictionary(csvString);
 
Console.WriteLine(results[0]["FirstName"]);
Dim csvReader As New CsvReader() 'Trial Mode
'Dim csvReader As New CsvReader("place user name here", "place license key here") 'License Mode            
 
Dim csvString As String = "FirstName,LastName" & vbCrLf & "John,Smith"
 
Dim results As List(Of Dictionary(Of String,String)) = csvReader.CsvStringToDictionary(csvString)
 
Console.WriteLine(results(0)("FirstName"))
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CsvReader Class
CsvReader Members