Split Process Data Standard Format method into multiple methods
This commit is contained in:
parent
6783621dab
commit
3e2fb15db0
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@ -11,6 +11,11 @@
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||
"args": [
|
||||
"s",
|
||||
"X",
|
||||
"L:/DevOps/EAF-Mesa-Integration/met08thftirqs408m/bin/Debug",
|
||||
"Day-Helper-2025-03-06",
|
||||
"*.pdsf",
|
||||
"s",
|
||||
"X",
|
||||
"D:/ProgramData/VisualStudioCode",
|
||||
|
@ -5,7 +5,35 @@ namespace File_Folder_Helper.ADO2025.PI5;
|
||||
internal static partial class Helper20250306
|
||||
{
|
||||
|
||||
private static string ProcessDataStandardFormatToJson(int columnsLine, string[] columns, string[] body)
|
||||
private static int? GetProcessDataStandardFormatColumnTitlesLine(string[] lines)
|
||||
{
|
||||
int? result = null;
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("END_OFFSET") && i + 2 < lines.Length)
|
||||
{
|
||||
result = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string? ProcessDataStandardFormatToLastDataLine(string[] lines, int columnTitlesLine)
|
||||
{
|
||||
string? result = null;
|
||||
for (int i = columnTitlesLine + 1; i < lines.Length; i++)
|
||||
{
|
||||
if (lines[i].StartsWith("NUM_DATA_ROWS"))
|
||||
{
|
||||
result = lines[i - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string ProcessDataStandardFormatToJson(int columnTitlesLine, string[] columns, string[] lines)
|
||||
{
|
||||
#pragma warning disable CA1845, IDE0057
|
||||
string result = "[\n";
|
||||
@ -13,11 +41,11 @@ internal static partial class Helper20250306
|
||||
string value;
|
||||
string[] segments;
|
||||
if (columns.Length == 0)
|
||||
columns = body[columnsLine].Trim().Split('\t');
|
||||
for (int i = columnsLine + 1; i < body.Length; i++)
|
||||
columns = lines[columnTitlesLine].Trim().Split('\t');
|
||||
for (int i = columnTitlesLine + 1; i < lines.Length; i++)
|
||||
{
|
||||
line = "{";
|
||||
segments = body[i].Trim().Split('\t');
|
||||
segments = lines[i].Trim().Split('\t');
|
||||
if (segments.Length != columns.Length)
|
||||
break;
|
||||
for (int c = 1; c < segments.Length; c++)
|
||||
@ -36,14 +64,22 @@ internal static partial class Helper20250306
|
||||
private static void ProcessDataStandardFormatToJson(ILogger<Worker> logger, string file)
|
||||
{
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
if (lines.Length < 7)
|
||||
int? columnTitlesLine = GetProcessDataStandardFormatColumnTitlesLine(lines);
|
||||
if (columnTitlesLine is null)
|
||||
logger.LogWarning("<{columnTitlesLine}> is null", nameof(columnTitlesLine));
|
||||
else
|
||||
{
|
||||
string? text = ProcessDataStandardFormatToLastDataLine(lines, columnTitlesLine.Value);
|
||||
File.WriteAllText(".lbl", text);
|
||||
if (lines.Length < columnTitlesLine.Value + 1)
|
||||
logger.LogWarning("<{lines}>(s)", lines.Length);
|
||||
else
|
||||
{
|
||||
string json = ProcessDataStandardFormatToJson(6, [], lines);
|
||||
string json = ProcessDataStandardFormatToJson(columnTitlesLine.Value, [], lines);
|
||||
File.WriteAllText(".json", json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ProcessDataStandardFormatToJson(ILogger<Worker> logger, List<string> args)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user