View difference between Paste ID: 9wUFuvpN and d1Z9t5d3
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.IO;
6
using System.Text.RegularExpressions;
7
using System.Diagnostics;
8
9
namespace deaths
10
{
11
    class Program
12
    {
13
        static void Main(string[] args)
14
        {
15
            String regexPattern = @"[a-z]?([\d]{2})([\d]{2})([\d]{4})([\d]{2})([\d]{2})([\d]{4})";
16
            Regex r = new Regex(regexPattern, RegexOptions.IgnoreCase);
17-
            long DeathsOnBday = 0, TotalDeaths = 0;
17+
            long DeathsOnBday = 0, TotalDeaths = 0, CharsRead = 0, DatesEmpty = 0, Iteration=0;
18-
            using (StreamReader sr = new StreamReader("C:/data/ssdm2/ssdm2"))
18+
            Console.WriteLine("Enter SSDI File Number You Wish To Read: ");
19
            string FileName = Console.ReadLine();
20
            string fName = "C:/data/ssdm" + FileName + "/ssdm" + FileName;
21
            Console.WriteLine(fName);
22
            using (StreamReader sr = new StreamReader(fName))
23
            {
24
                String line;
25
                var sw = Stopwatch.StartNew();
26
                while ((line = sr.ReadLine()) != null)
27
                {
28
                    int m1,d1,y1,m2,d2,y2;
29
                    //Console.WriteLine(line);
30
                    CharsRead += line.Length; //Keep track of bytes read/Iterations of the loop
31
                    Iteration++;
32
                    MatchCollection matches = r.Matches(line);
33
                    m1 = Convert.ToInt32(matches[0].Groups[1].Value);
34-
                    //If month and date of birth match and aren't recorded as 0
34+
35-
                    if (m1 == m2 && d1 == d2 && d1 != 0 && m1 != 0)
35+
36
                    m2 = Convert.ToInt32(matches[0].Groups[4].Value);
37
                    d2 = Convert.ToInt32(matches[0].Groups[5].Value);
38
                    y2 = Convert.ToInt32(matches[0].Groups[6].Value);
39-
                    if (TotalDeaths % 10000 == 0)
39+
40
                    //Some progress code to calculate how much more time I have left...
41
                    if (Iteration % 500000 == 0)
42
                    {
43
                        sw.Stop();
44-
                            Console.Title = (10000.0 / (sw.ElapsedMilliseconds/1000.0)).ToString() + " Iterations Per Second";
44+
45
                        {
46
                            Console.Title = (500000.0 / (sw.ElapsedMilliseconds / 1000.0)).ToString() + " Iterations Per Second " +
47
                                ((CharsRead / 1048576) / (sw.ElapsedMilliseconds / 1000.0)).ToString() + " MB Per Second";
48
                        }
49
                        CharsRead = 0;
50-
                    //Console.WriteLine(m1 + " " + d1 + " " + y1 + " - " + m2 + " " + d2 + " " + y2);
50+
51
                        sw.Start();
52
                    }
53
54-
            Console.WriteLine(DeathsOnBday + "/" + TotalDeaths);            
54+
                    //If their months/day/year are 0's, it's probably beacuse the SS didn't record it
55
                    if (d1 == 0 || m1 == 0 || y1 == 0 || d2 == 0 || m2 == 0 || y2 == 0)
56
                    {
57
                        DatesEmpty++;
58
                        continue;
59
                    }
60
                    //If month and date of birth match
61
                    if (m1 == m2 && d1 == d2)
62
                    {
63
                        DeathsOnBday++;
64
                    }
65
66
                    TotalDeaths++;
67
                }
68
            }
69
            Console.WriteLine(DeathsOnBday + "/" + TotalDeaths + " " + Iteration + " - " + DatesEmpty);            
70
            Console.ReadLine();
71
        }
72
    }
73
}