Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Globalization;
- using CsvHelper;
- using scratchpad;
- internal sealed class JustRatings
- {
- public string Epee { get; set; }
- public string Foil { get; set; }
- public string Saber { get; set; }
- }
- public class Program
- {
- public static void Main()
- {
- // !!reduced membership csv to just the 3 ratings columns!!
- // read the file
- using var reader = new StreamReader(@"<path to file>");
- using var csv = new CsvReader(reader, CultureInfo.InvariantCulture);
- // get the records
- var records = csv.GetRecords<JustRatings>().ToList();
- // make things easier
- var allSaber = records.Select(record => record.Saber).ToList();
- var allFoil = records.Select(record => record.Foil).ToList();
- var allEpee = records.Select(record => record.Epee).ToList();
- // do calculations
- var epeeRated = allEpee.Count(x => x != "U");
- var epeeUnrated = allEpee.Count - epeeRated;
- var foilRated = allFoil.Count(x => x != "U");
- var foilUnrated = allFoil.Count - foilRated;
- var saberRated = allSaber.Count(x => x != "U");
- var saberUnrated = allSaber.Count - saberRated;
- Console.WriteLine($"% of Epee fencers that are rated: {epeeRated / (double)allEpee.Count * 100}");
- Console.WriteLine($"% of Foil fencers that are rated: {foilRated / (double)allFoil.Count * 100}");
- Console.WriteLine($"% of Saber fencers that are rated: {saberRated / (double)allSaber.Count * 100}");
- Console.WriteLine($"More details:\nEpee Rated #: {epeeRated} | Epee Unrated #: {epeeUnrated}\nFoil Rated #: {foilRated} | Foil Unrated #: {foilUnrated}\nSaber Rated #: {saberRated} | Saber Unrated #: {saberUnrated}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment