public static void WriteRecords(NameComponentSources nameComponentSources, int count, string outputPath) { using (var writer = new StreamWriter(outputPath)) { writer.WriteLine("Name1\tName2\tName3\tCity\tState\tZIPCode\tSurname1\tSurname2\tFormOfBusiness\tPrefix\tSuffix\tPlaceName"); for (int i = 0; i < count; i++) { var bnc = nameComponentSources.GenerateNewBusinessName(); var recordComponents = new string[] { bnc[0], bnc[1], bnc[2], bnc.PlaceName.ZipCity, bnc.PlaceName.ZipState, bnc.PlaceName.ZipCode, bnc.Surname1, bnc.Surname2, bnc.LegalWord, bnc.Prefix, bnc.Suffix, bnc.PlaceName.Name }; writer.WriteLine(String.Join('\t', recordComponents)); } writer.Flush(); writer.Close(); } }
static void Main(string[] args) { var outputPath = "output.txt"; var n = 10000000; var nameComponentSources = new NameComponentSources() { PlaceNames = PlaceNameLoader.Load("Data/place_names.txt"), Surnames = SurnameLoader.Load("Data/surnames_us.txt"), Suffixes = File.ReadAllLines("Data/business_suffixes.txt"), Prefixes = File.ReadAllLines("Data/business_prefixes.txt"), FormsOfBusiness = File.ReadAllLines("Data/legal_control_words.txt") }; var sw = Stopwatch.StartNew(); FakeBusinessWriter.WriteRecords(nameComponentSources, n, outputPath); sw.Stop(); Console.WriteLine($"Created {n} businesses in {sw.ElapsedMilliseconds}ms"); }