person-key-to-immich-import birthday json (Day-Helper-2024-05-18)
csharp_prefer_braces = true
This commit is contained in:
@ -8,23 +8,24 @@ internal static partial class Helper20250306 {
|
||||
string searchPattern = args[2];
|
||||
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly);
|
||||
if (files.Length != 1)
|
||||
if (files.Length != 1) {
|
||||
logger.LogWarning("<{files}>(s)", files.Length);
|
||||
else
|
||||
} else {
|
||||
ProcessDataStandardFormatToJson(logger, files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessDataStandardFormatToJson(ILogger<Worker> logger, string file) {
|
||||
string[] lines = File.ReadAllLines(file);
|
||||
int? columnTitlesLine = GetProcessDataStandardFormatColumnTitlesLine(lines);
|
||||
if (columnTitlesLine is null)
|
||||
if (columnTitlesLine is null) {
|
||||
logger.LogWarning("<{columnTitlesLine}> is null", nameof(columnTitlesLine));
|
||||
else {
|
||||
} else {
|
||||
string? text = ProcessDataStandardFormatToLastDataLine(lines, columnTitlesLine.Value);
|
||||
File.WriteAllText(Path.Combine(".vscode", "helper", ".lbl"), text);
|
||||
if (lines.Length < columnTitlesLine.Value + 1)
|
||||
if (lines.Length < columnTitlesLine.Value + 1) {
|
||||
logger.LogWarning("<{lines}>(s)", lines.Length);
|
||||
else {
|
||||
} else {
|
||||
string json = ProcessDataStandardFormatToJson(columnTitlesLine.Value, [], lines);
|
||||
File.WriteAllText(Path.Combine(".vscode", "helper", ".json"), json);
|
||||
}
|
||||
@ -35,8 +36,9 @@ internal static partial class Helper20250306 {
|
||||
int? result = null;
|
||||
bool foundEndOfFile = false;
|
||||
for (int i = 0; i < lines.Length; i++) {
|
||||
if (lines[i] == "EOF")
|
||||
if (lines[i] == "EOF") {
|
||||
foundEndOfFile = true;
|
||||
}
|
||||
if (foundEndOfFile && lines[i].StartsWith("END_OFFSET") && i + 3 < lines.Length) {
|
||||
result = i + 2;
|
||||
break;
|
||||
@ -62,14 +64,16 @@ internal static partial class Helper20250306 {
|
||||
string line;
|
||||
string value;
|
||||
string[] segments;
|
||||
if (columns.Length == 0)
|
||||
if (columns.Length == 0) {
|
||||
columns = lines[columnTitlesLine].Trim().Split('|');
|
||||
}
|
||||
int columnsLength = columns.Length - 2;
|
||||
for (int i = columnTitlesLine + 1; i < lines.Length; i++) {
|
||||
line = "{";
|
||||
segments = lines[i].Trim().Split('|');
|
||||
if (segments.Length != columnsLength)
|
||||
if (segments.Length != columnsLength) {
|
||||
continue;
|
||||
}
|
||||
for (int c = 1; c < segments.Length; c++) {
|
||||
value = segments[c].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||
line += '"' + columns[c].Trim('"') + '"' + ':' + '"' + value + '"' + ',';
|
||||
|
Reference in New Issue
Block a user