With following assumptions,
- Every values is separated by
,
and your input is one long string with the mentioned pattern.
- The first row has column names.
.You could do this using these Linq
statements.
string input = @"Date,Open,High,Low,Close,Volume,AdjClose,
2016-05-06,49.919998,50.389999,49.66,50.389999,24715600,50.389999,
2016-05-05,49.869999,50.299999,49.73,49.939999,25309500,49.939999,
2016-05-04,49.84,50.060001,49.459999,49.869999,24171400,49.869999";
var stacks = input.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries)
.Select((x,i)=> new {index= i/7, item=x }) // split with 7 columns
.Where(x=>x.index !=0) // skip header row.
.GroupBy(x=>x.index)
.Select(x=> new Stack()
{
Date = DateTime.ParseExact(x.First().item.Trim(),"yyyy-MM-dd", CultureInfo.InvariantCulture),
Open = double.Parse(x.Skip(1).First().item),
High = double.Parse(x.Skip(2).First().item),
Low = double.Parse(x.Skip(3).First().item),
Close = double.Parse(x.Skip(4).First().item),
Volume = double.Parse(x.Skip(5).First().item),
AdjClose = double.Parse(x.Skip(6).First().item),
})
.ToList();
Check this Demo