-1

I took the input from the csv file, processed and stored the results in the List of Objects of the 'OutputRecords' class. I used Lumenworks CsvReader for this task. Please help me out so as to how to create a new csv File and write the output to the user.

The members of the class are:

public int individuals;
    public int count;
    public string botanical_Name;
    public double density;
    public double species_Basal_Area;
    public double frequency;
    public double relative_Frequency;
    public double relative_Density;
    public double relative_Basal_Area;
    public double ivi_Value;

The list below consists of objects contain the output that is to be written to a csv file.

List<OutputRecords> object_OutputRecords = new List<OutputRecords>();
Madhur
  • 1
  • 1

1 Answers1

0

you can use a library such as http://joshclose.github.io/CsvHelper/ to serialize the list for you.

example

using(var textWriter = File.OpenWrite("output.csv"))
{
    var csv = new CsvWriter( textWriter ); 
    csv.WriteRecords( object_OutputRecords ); 
}

this will create a file called output.csv and write all the records in the collection to it.

tocsoft
  • 1,709
  • 16
  • 22