I feel quite embarrassed to ask this, but I simply cannot get my desired results.
I have a CSV file which looks like this:
Col_Title_1|Col_Title_2|Col_Title_3|Col_Title_4|Col_Title_5
Value_1 | Value_2 | Value_3 | Value_4 | Value_5
I want to read this data and manipulate it such as (pseudo code):
var test = array.Column("Col_Title_3").Value;
I just can't seem to pair the column and value up accordingly.
Is a dictionary or KeyValuePair best to use?
Here is 1 good test I did but of course does not work 100%:
Dictionary<string, string> dict = File.ReadLines(e.FullPath).Select(line =>
line.Split('|')).ToDictionary(line => line[0], line => line[1]);
I know I can do a hacky/hard code way like so:
string lineValues = File.ReadLines(e.FullPath).ElementAt(1);
string row3 = lineValues.Split('|')[2];
string row5 = lineValues.Split('|')[4];
But for obvious reasons I do not want to do it like this.
Any help will be greatly appreciated! Thanks all!