My question is different from other SO questions, because those deserialization samples are for a typed<Customer> POCO class
, in my scenario I don't have any types ahead of time. Files are being dropped in a folder from various sources.
Without, the type or header information, how would I deserialize/read a CSV file with unknown headers to a List<>, JSON Array or Enumerable (I don't need a datatable)
using System;
using System.Data;
using System.Collections;
using System.Linq;
using ChoETL;
using System.Text;
public class Program
{
public static void Main()
{
//headers are not known in the SourceFile.csv - i need a list and headers
//var csvLisFromCho = new ChoCSVReader(@"SourceFile.csv").WithFirstLineHeader();
StringBuilder csvIn = new StringBuilder(@"ID,Name
1, David
2, Bob");
using (var r = new ChoCSVReader(csvIn).WithFirstLineHeader())
{
var list = r.Select(r1 => r1.Values).ToList();
Console.WriteLine("Coverted List from Raj");
list.ForEach(Console.WriteLine);
}
}
}