Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Text.RegularExpressions;
- using System.Diagnostics;
- namespace deaths
- {
- class Program
- {
- static void Main(string[] args)
- {
- String regexPattern = @"[a-z]?([\d]{2})([\d]{2})([\d]{4})([\d]{2})([\d]{2})([\d]{4})";
- Regex r = new Regex(regexPattern, RegexOptions.IgnoreCase);
- long DeathsOnBday = 0, TotalDeaths = 0, CharsRead = 0, DatesEmpty = 0, Iteration=0;
- Console.WriteLine("Enter SSDI File Number You Wish To Read: ");
- string FileName = Console.ReadLine();
- string fName = "C:/data/ssdm" + FileName + "/ssdm" + FileName;
- Console.WriteLine(fName);
- using (StreamReader sr = new StreamReader(fName))
- {
- String line;
- var sw = Stopwatch.StartNew();
- while ((line = sr.ReadLine()) != null)
- {
- int m1,d1,y1,m2,d2,y2;
- //Console.WriteLine(line);
- CharsRead += line.Length; //Keep track of bytes read/Iterations of the loop
- Iteration++;
- MatchCollection matches = r.Matches(line);
- m1 = Convert.ToInt32(matches[0].Groups[1].Value);
- d1 = Convert.ToInt32(matches[0].Groups[2].Value);
- y1 = Convert.ToInt32(matches[0].Groups[3].Value);
- m2 = Convert.ToInt32(matches[0].Groups[4].Value);
- d2 = Convert.ToInt32(matches[0].Groups[5].Value);
- y2 = Convert.ToInt32(matches[0].Groups[6].Value);
- //Some progress code to calculate how much more time I have left...
- if (Iteration % 500000 == 0)
- {
- sw.Stop();
- if (sw.ElapsedMilliseconds > 0)
- {
- Console.Title = (500000.0 / (sw.ElapsedMilliseconds / 1000.0)).ToString() + " Iterations Per Second " +
- ((CharsRead / 1048576) / (sw.ElapsedMilliseconds / 1000.0)).ToString() + " MB Per Second";
- }
- CharsRead = 0;
- sw.Reset();
- sw.Start();
- }
- //If their months/day/year are 0's, it's probably beacuse the SS didn't record it
- if (d1 == 0 || m1 == 0 || y1 == 0 || d2 == 0 || m2 == 0 || y2 == 0)
- {
- DatesEmpty++;
- continue;
- }
- //If month and date of birth match
- if (m1 == m2 && d1 == d2)
- {
- DeathsOnBday++;
- }
- TotalDeaths++;
- }
- }
- Console.WriteLine(DeathsOnBday + "/" + TotalDeaths + " " + Iteration + " - " + DatesEmpty);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement