-
Notifications
You must be signed in to change notification settings - Fork 2
/
NugetDemo.linq
37 lines (33 loc) · 998 Bytes
/
NugetDemo.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<Query Kind="Program">
<NuGetReference>CsvHelper</NuGetReference>
<Namespace>analyticsLibrary.dbObjects</Namespace>
<Namespace>analyticsLibrary.library</Namespace>
<Namespace>CsvHelper</Namespace>
</Query>
void Main()
{
var verdictFile = @"C:\github\LINQPad-Demo\deathpenaltyverdicts.csv";
var reader = new StreamReader(verdictFile);
var verdictsCsv = new CsvReader(reader);
var verdicts = verdictsCsv
.GetRecords<verdict>();
//.ToArray(); //try leaving this off
verdicts
//.Where(v => v.Penalty == "Death")
//.Where(v => v.Defendant == "White")
//.GroupBy(v => new { v.Penalty, v.Defendant, v.Victim })
//.Select(v => new
//{
// Races = v.Key,
// Percentage = ((double)v.Count() / verdicts.Count()).ToString("###.0%"),
// //raw = ((double)v.Count() / verdicts.Count())
//})
//.OrderByDescending(v => v.Percentage)
.Dump();
}
class verdict
{
public string Penalty{ get; set; }
public string Victim { get; set; }
public string Defendant { get; set; }
}