Very simple C# CSV reader
Solution 1:
You can try the some thing like the below LINQ snippet.
string[] allLines = File.ReadAllLines(@"E:\Temp\data.csv");
var query = from line in allLines
let data = line.Split(',')
select new
{
Device = data[0],
SignalStrength = data[1],
Location = data[2],
Time = data[3],
Age = Convert.ToInt16(data[4])
};
UPDATE: Over a period of time, things evolved. As of now, I would prefer to use this library http://www.aspnetperformance.com/post/LINQ-to-CSV-library.aspx
Solution 2:
If there is only ever one line then do something like this:
using System;
using System.IO;
class Program
{
static void Main()
{
String[] values = File.ReadAllText(@"d:\test.csv").Split(',');
}
}