I have a CSV file that I want to read into a List. Here\'s an example file:
Plant,Material,\"Density, Lb/ft3\",Storage Location
FRED,10000477,64.3008,3300
F
With Cinchoo ETL library, can parse CSV file into objects
Define type matching CSV file structure as below
public class PlantType
{
public string Plant { get; set; }
public int Material { get; set; }
public double Density { get; set; }
public int StorageLocation { get; set; }
}
Load the CSV file
static void LoadCSV()
{
using (var p = new ChoCSVReader("*** YOUR CSV FILE PATH ***")
.WithFirstLineHeader(true)
)
{
foreach (var rec in p)
{
Console.WriteLine(rec.Dump());
}
}
}