From 7bf087b3edf23e32635407584a8f5fa3ac98ff72 Mon Sep 17 00:00:00 2001 From: ened Date: Thu, 1 Jun 2023 09:46:32 +0900 Subject: [PATCH] Update batch function & data --- KissMeConsole/Sources/main.swift | 2 -- KissMeConsole/Sources/test.swift | 14 +++++++++++--- bin/data | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/KissMeConsole/Sources/main.swift b/KissMeConsole/Sources/main.swift index 387a388..59b95cf 100644 --- a/KissMeConsole/Sources/main.swift +++ b/KissMeConsole/Sources/main.swift @@ -8,5 +8,3 @@ import Foundation KissConsole().run() - -//move_candles_to_min_subdir() diff --git a/KissMeConsole/Sources/test.swift b/KissMeConsole/Sources/test.swift index b0db32f..d109794 100644 --- a/KissMeConsole/Sources/test.swift +++ b/KissMeConsole/Sources/test.swift @@ -161,7 +161,10 @@ private func check_candle_csv() { } -func move_candles_to_min_subdir() { +private func move_candles_to_min_subdir() { + // Move all of csv into min sub-directory + // ex) data/000020/candle-20230530.csv --> /data/000020/min/candle-20230530.csv + // guard let enumerator = subPathFiles("data") else { return } @@ -177,13 +180,18 @@ func move_candles_to_min_subdir() { for fileUrl in urls { let fileName = fileUrl.lastPathComponent let upper = fileUrl.deletingLastPathComponent() + let productNo = upper.lastPathComponent + + guard let _ = Int(productNo) else { + continue + } let newPath = upper.appending(path: "min") let newUrl = newPath.appending(path: fileName) - + //print("file: \(fileUrl) -> \(newUrl)") do { - try FileManager.default.createDirectory(at: upper, withIntermediateDirectories: true) + try FileManager.default.createDirectory(at: newPath, withIntermediateDirectories: true) try FileManager.default.moveItem(at: fileUrl, to: newUrl) } catch { diff --git a/bin/data b/bin/data index e62d901..d102289 160000 --- a/bin/data +++ b/bin/data @@ -1 +1 @@ -Subproject commit e62d901f86637a29b837183123db74dbc26fe51f +Subproject commit d102289c456fe97d145ad5bae7d237075b9b3f57