- Install package
dotnet add package wk.CsvGenerator
- Include CSV template as additional file in
.csproj
<ItemGroup>
<AdditionalFiles Include="B.csv" />
</ItemGroup>
- Create partial class and place
CsvGeneratorAttribute
- Parse CSV with loader utility
using System;
using System.IO;
namespace MyApp {
[CsvGenerator(Template = "B.csv")]
public partial class Industry { }
public class Program {
public static void Main() {
var csv = File.ReadAllText("resource/csv/B.csv");
var data = IndustryLoader.Parse(csv);
foreach (var item in data) {
Console.WriteLine($"{item.Year} {item.VariableCategory,50}");
}
}
}
}