I am using the following code and getting an exception ,
Exception thrown: 'CsvHelper.WriterException' in CsvHelper.dll on this line executed:
csv.WriteRecord(item);
This is the more of the code:
using (var memoryStream = new MemoryStream())
{
using (var writer = new StreamWriter(memoryStream))
{
using (var csv = new CsvHelper.CsvWriter(writer, System.Globalization.CultureInfo.CurrentCulture))
{
foreach (var item in csvData)
{
csv.WriteRecord(item); // Exception thrown here
}
}
}
var arr = memoryStream.ToArray();
//js.SaveAs("people.csv", arr); what type object is js? copied from the stackoverflow answer linked here
}
This is the csvData code:
IEnumerable<DateLowHigh> csvData = stocks.candles
.Select(c => new DateLowHigh
{
Time = c.datetime,
Close = c.close,
Low = c.low,
High = c.high
})
.ToList();
I do get the csvData.
This stackoverflow answer helped me get started.