CSV Reports
CsvFileToDictionary Method
Example 



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

Parameters

filePath
The fully qualified file path

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
 
//Create a test file
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testReader.csv");
File.WriteAllText(filePath, "Name,Birthdate\r\nJohn,5/30/2013");
 
List<Dictionary<string, string>> results = csvReader.CsvFileToDictionary(filePath);
Console.WriteLine(results[0]["Name"]);
Dim csvReader As New CsvReader() 'Trial Mode
'Dim csvReader As New CsvReader("place user name here", "place license key here") 'License Mode
 
'Create a test file
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testReader.csv")
File.WriteAllText(filePath, "Name,Birthdate" & vbCrLf & "John,5/30/2013")
 
Dim results As List(Of Dictionary(Of String, String)) = csvReader.CsvFileToDictionary(filePath)
Console.WriteLine(results(0)("Name"))
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