From a669bf52da5d595b86853e4016627f5303f75b22 Mon Sep 17 00:00:00 2001 From: Thom Lamb Date: Tue, 12 May 2026 10:41:06 -0500 Subject: [PATCH] chore: deploy initial code base --- Program.cs | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ splitfile.csproj | 10 ++++++ splitfile.sln | 25 +++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 Program.cs create mode 100644 splitfile.csproj create mode 100644 splitfile.sln diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..fef42a3 --- /dev/null +++ b/Program.cs @@ -0,0 +1,80 @@ +public class Program +{ + + public static void Main() + { + var path = @"C:\Users\tlamb\Downloads\AccessGUDID_Delimited_Full_Release_20231001"; + var input = "gmdnTerms.txt"; + var format = "gmdnTerms-{0:000}.txt"; + //var input = "device.txt"; + //var format = "device-{0:000}.txt"; + var size = int.MaxValue; + var info = new FileInfo(Path.Combine(path, input)); + size = (int)Math.Min(info.Length / 10, size); + Split(Path.Combine(path, input), Path.Combine(path, format), size); + } + + public static void Split(string inputfile, string outputfilesformat, int maxSize = int.MaxValue, bool hasHeader = true) + { + int i = 0; + int size = 0; + StreamWriter outfile = null; + bool firstFile = true; + string headerLine = null; + string line; + + try + { + using (var infile = new StreamReader(inputfile)) + { + while (!infile.EndOfStream) + { + line = infile.ReadLine(); + if (hasHeader && headerLine == null) + { + headerLine = line; + } + if (size > maxSize) + { + if (outfile != null) + { + outfile.Dispose(); + outfile = null; + size = 0; + } + } + if (string.IsNullOrEmpty(line)) + { + if (outfile != null) + { + outfile.Dispose(); + outfile = null; + size = 0; + } + continue; + } + if (outfile == null) + { + outfile = new StreamWriter( + string.Format(outputfilesformat, i++), + false, + infile.CurrentEncoding); + if (!firstFile && hasHeader) + { + outfile.WriteLine(headerLine); + } + firstFile = false; + } + outfile.WriteLine(line); + size += line.Length; + } + + } + } + finally + { + if (outfile != null) + outfile.Dispose(); + } + } +} \ No newline at end of file diff --git a/splitfile.csproj b/splitfile.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/splitfile.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/splitfile.sln b/splitfile.sln new file mode 100644 index 0000000..f643cd8 --- /dev/null +++ b/splitfile.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "splitfile", "splitfile.csproj", "{3687F04B-882A-4524-BAD7-1E7D68B3661C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3687F04B-882A-4524-BAD7-1E7D68B3661C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3687F04B-882A-4524-BAD7-1E7D68B3661C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3687F04B-882A-4524-BAD7-1E7D68B3661C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3687F04B-882A-4524-BAD7-1E7D68B3661C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C6388701-C197-4C93-8B96-20A593AEF339} + EndGlobalSection +EndGlobal -- 2.54.0