Note that there are some explanatory texts on larger screens.

plurals
  1. POGet,Set using Lists in C# ...Help Needed
    primarykey
    data
    text
    <p>I need to read a CSV file in C# and drop the data into a list and then dump the data to a SQL Database database.</p> <p>The class I'm interested using is using CsvHelper.</p> <p>This is two sample data in the CSV File:</p> <pre><code>1,2013-05-14,NISSAN,059 7013,1995,VAN,Deisel,NISSAN,0000,NISSAN,Red,MARADANA,op1,description,p1.jpg+p2.jpg+p3.jpg,r1+r2+r3 2,2013-05-14,NISSAN2,059-7013,1995,VAN,Deisel,NISSAN,0000,NISSAN,Red,MARADANA,op1,description,p1.jpg+p2.jpg+p3.jpg,r1+r2+r3 </code></pre> <p>This is the class for the CSV file</p> <pre><code>class Vehicle { public int ID { get; set; } public string ClosingDate { get; set; } public string Model { get; set; } public string Reg { get; set; } public string YearOfManufacture { get; set; } public string VehicleType { get; set; } public string Fuel { get; set; } public string Brand { get; set; } public string Mileage { get; set; } public string Make { get; set; } public string Colour { get; set; } public string VehicleYard { get; set; } public string BasicOptions { get; set; } public string Description { get; set; } public List&lt;string&gt; Photos { get; set; } public List&lt;string&gt; Regions { get; set; } } </code></pre> <p>I tried and read the CSV file using this code:</p> <pre><code>namespace ConsoleApplication2 { class Program { static void Main(string[] args) { CsvHelperRead(); Console.Read(); } private static void CsvHelperRead() { CsvConfiguration config = new CsvConfiguration(); config.HasHeaderRecord = false; using (var reader = new CsvReader(new StreamReader(@"C:\Users\afshandc\Desktop\0729\vTest.csv"), config)) { while (reader.Read()) { Console.WriteLine(reader.GetField(1)); } } } } } </code></pre> <p>I need to read the CSV file and drop it to this list.</p> <pre><code> class CSV { public List&lt;Vehicle&gt; ReadVechileCSV() { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload