Setting Row Headers In A CSV
-
Tuesday, March 13, 2012 10:54 AM
- Edited by matta0990 Tuesday, March 13, 2012 3:46 PM error
All Replies
-
Tuesday, March 13, 2012 12:38 PM
No error checking here to ensure that each row actually contains the columns, but you get the idea:
List<string[]> parsedData = new List<string[]>(); using (StreamReader readfile = new StreamReader(path)) { string line; string[] row; while ((line = readfile.ReadLine()) != null) { row = line.Split(','); parsedData.Add(new string[]{row[5], row[8]}); } }
Additionally, I would look for a better storage mechanism than a List of strings, perhaps a List of classes that would better describe the data.
It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
- Edited by TSoftware Tuesday, March 13, 2012 12:39 PM Left off closing }
- Proposed As Answer by TSoftware Thursday, March 15, 2012 2:17 PM
- Marked As Answer by Bob ShenMicrosoft Contingent Staff, Moderator Monday, March 26, 2012 2:42 AM
-
Tuesday, March 13, 2012 3:41 PM
hi,
I have a CSV and need to be able to brake down each row and column so that I can select indervidual cells within the CSV and set them as an object (i think). I would like to select the "Date" from the CSV which may be in "C3" and a value which may be in "C7" and nothing else.
Is this possible?
- Merged by Bob ShenMicrosoft Contingent Staff, Moderator Thursday, March 15, 2012 8:01 AM duplicate
-
Tuesday, March 13, 2012 3:55 PM
You may want to take a look at this post:
Since it is almost identical to what you had posted there.
It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.
- Edited by TSoftware Tuesday, March 13, 2012 3:55 PM
- Proposed As Answer by servy42Microsoft Community Contributor Tuesday, March 13, 2012 6:30 PM

