Help needed guys! I'm writing a simple import application an need to read a csv file. Show result in a datagrid and show corrupted lines of csv file in another grid, for example show the lines that are shorter than 5 values in another grid. I'm trying to do that like this:
StreamReader sr = new StreamReader(FilePath);
importingData = new Account();
string line;
string[] row = new string [5];
while ((line = sr.ReadLine()) != null)
{
row = line.Split(',');
importingData.Add(new Transaction
{
Date = DateTime.Parse(row[0]),
Reference = row[1],
Description = row[2],
Amount = decimal.Parse(row[3]),
Category = (Category)Enum.Parse(typeof(Category), row[4])
});
}
but its very difficult to operate on arrays in this case. Is there any better way to split the values. Any suggestions appreciated
Thanks guys. The information you provided was very useful. I found another way doing that using DataTable. Very interesting approach, here is the link : link text