// ExtractDateTimePattern extracts the date_time pattern from a filename
// Looks for patterns: YYYYMMDD_HHMMSS (8 digits) or YYMMDD_HHMMSS/DDMMYY_HHMMSS (6 digits)
// Returns the pattern and whether it was found
// Example: "A05-20250517_214501" -> ("20250517_214501", true)
// ExtractDateTimePattern extracts 6-digit or 8-digit date patterns from filenames
func ExtractDateTimePattern(filename string) (pattern string, found bool) {
// Pattern: 8 digits + underscore + 6 digits (YYYYMMDD_HHMMSS)
pattern8 := regexp.MustCompile(`(\d{8}_\d{6})`)
if match := pattern8.FindString(filename); match != "" {
return match, true
}
// Pattern: 6 digits + underscore + 6 digits (YYMMDD_HHMMSS or DDMMYY_HHMMSS)
pattern6 := regexp.MustCompile(`(\d{6}_\d{6})`)
if match := pattern6.FindString(filename); match != "" {
return match, true
}
return "", false
}
# db export not working anymore
(base) skraak ➤ duckdb db/test.duckdb
DuckDB v1.4.4 (Andium) 6ddac802ff
Enter ".help" for usage hints.
D select * from dataset;
┌──────────────┬──────────────────────┬───┬──────────────────────┬─────────┬──────────────────────┐
│ id │ name │ … │ last_modified │ active │ type │
│ varchar │ varchar │ │ timestamp with tim… │ boolean │ enum('structured',… │
├──────────────┼──────────────────────┼───┼──────────────────────┼─────────┼──────────────────────┤
│ gljgxDbfasva │ Twenty Four Seven │ … │ 2025-05-30 20:12:3… │ true │ structured │
│ Yx0oNUDmP5ch │ Pomona - Kiwi │ … │ 2025-06-29 15:28:4… │ true │ structured │
│ wAJk9wuZN15x │ Bluemine - Kiwi │ … │ 2025-06-29 15:28:5… │ true │ structured │
│ jWS-sw5RvM-j │ Pure Salt - Kiwi │ … │ 2025-06-30 08:36:1… │ true │ structured │
│ QZ0tlUrX4Nyi │ Friends of Cobb - … │ … │ 2025-06-02 05:46:1… │ true │ structured │
│ la-JpAf2nLKG │ Manu o Kahurangi -… │ … │ 2025-08-26 20:27:5… │ true │ structured │
│ 0gQLE0Rq8c2J │ Moraine Creek - Kiwi │ … │ 2026-02-01 12:50:2… │ true │ structured │
│ lbget6lz7zTi │ HCT - Kiwi │ … │ 2026-02-01 13:06:3… │ true │ structured │
│ RxajkKXz-w48 │ Lisa Whittle - Kiwi │ … │ 2025-07-22 13:21:0… │ true │ structured │
│ v7NY9PqEysb6 │ DOC Tier 1 Tokoeka… │ … │ 2026-02-02 11:25:5… │ true │ structured │
│ f24ajtZdbv5Y │ Tuning Fork Record… │ … │ 2026-02-02 15:36:5… │ true │ structured │
│ 60BF5sloxvNA │ Secretary Island │ … │ 2026-02-03 07:44:4… │ true │ structured │
│ hFBFNcqTsgp2 │ Wendy Ambury Bittern │ … │ 2026-02-03 14:47:0… │ true │ structured │
│ ZhveWT897gpy │ Friends of Flora -… │ … │ 2026-02-08 12:37:1… │ true │ structured │
│ 4Sh8_7p1ocks │ Andrew Digby - LSK │ … │ 2026-02-14 13:58:0… │ true │ unstructured │
│ -xY_NuNbgQGO │ EventLogTest_17766… │ … │ 2026-04-20 10:45:2… │ true │ structured │
│ VOFJTXOypNso │ Bulk Import Test D… │ … │ 2026-04-20 10:46:0… │ true │ structured │
├──────────────┴──────────────────────┴───┴──────────────────────┴─────────┴──────────────────────┤
│ 17 rows 7 columns (5 shown) │
└─────────────────────────────────────────────────────────────────────────────────────────────────┘
D .quit
(base) skraak ➤ skraak export dataset --db db/test.duckdb --id 60BF5sloxvNA --output test.duckdb
Error: failed to copy species: Constraint Error: Violates foreign key constraint because key "species_code: morepo2, taxonomy_version: 2024" does not exist in the referenced table