I have a list:
IList<PIData> list = new List<PIData>()
This returns a list like this:
Timestamp | End | HeaderTitle | Value
=========================================================
12/12/2012 00:00 | 12/12/2012 00:01 | Test1 | 0.23
12/12/2012 00:00 | 12/12/2012 00:01 | Test2 | 0.34
12/12/2012 00:00 | 12/12/2012 00:01 | Test3 | 0.556
This continues on and on where sometimes I will have 50-100 different HeaderTitles
I need to be able to pivot this and ultimately write it to a CSV with Row being a header. I know how to convert an object to CSV but I am having a super hard time pivoting the list and hoping someone can help.
here is what I want to it to look like:
Timestamp | End | Test1 | Test2 | Test3 | etc
==================================================================
12/12/2012 00:00 | 12/12/2012 00:01 | 0.23 | 0.34 | 0.556
12/12/2012 00:01 | 12/12/2012 00:02 | 0.23 | 0.34 | 0.556
12/12/2012 00:02 | 12/12/2012 00:03 | 0.23 | 0.34 | 0.556
Can someone help me make this work? I really just need to be able to pivot my List to a new List that will ultimately be a CSV file... I know how to do it in SQL but I cannot use SQL in this scenario.
Here is what I ended up doing what worked for me: