Created
March 25, 2016 18:19
-
-
Save yallie/3c2d2a848aa972b91da3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile: "c:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe" ParseCsv.cs /r:CsvHelper.dll | |
// Depends on: https://www.nuget.org/packages/CsvHelper/ | |
// Source code: http://joshclose.github.io/CsvHelper/#change-log | |
using System; | |
using System.IO; | |
using System.Xml; | |
using System.Xml.Linq; | |
using CsvHelper; | |
class Program | |
{ | |
static void Main() | |
{ | |
using (var reader = new StreamReader(File.OpenRead("SampleInput1.csv"))) | |
{ | |
var csv = new CsvReader(reader); | |
var records = csv.GetRecords<Record>(); | |
foreach (var record in records) | |
{ | |
Console.WriteLine("-----------"); | |
Console.WriteLine(record); | |
} | |
} | |
} | |
} | |
class Record | |
{ | |
public int Site { get; set; } | |
public int Format { get; set; } | |
public string Title { get; set; } | |
public string Variations { get; set; } | |
public XDocument XmlVariations { get { return XDocument.Parse(Variations); } } | |
public override string ToString() | |
{ | |
return $"Site: {Site}, Format: {Format}, Title: {Title}, Variations: {XmlVariations}"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment