Csv Extension in Konstante ausgelagert.

This commit is contained in:
Marco Kittel 2025-06-28 17:51:52 +02:00
parent 531bb5ba41
commit bf86ab9c83
1 changed files with 9 additions and 6 deletions

View File

@ -10,6 +10,8 @@ import (
"gittea.marcokittel.de/elio/eliotools/tools" "gittea.marcokittel.de/elio/eliotools/tools"
) )
const FileExt = "csv"
type filedata struct { type filedata struct {
filename string filename string
dt time.Time dt time.Time
@ -18,11 +20,12 @@ type ElioHandleFunc func(filename string) bool
type ElioDateiFoo struct { type ElioDateiFoo struct {
process ElioHandleFunc process ElioHandleFunc
dir string lookUpDir string
processedDir string
} }
func NewElioDateiFoo(dir string, process ElioHandleFunc) *ElioDateiFoo { func NewElioDateiFoo(lookUpDir string, process ElioHandleFunc) *ElioDateiFoo {
df := ElioDateiFoo{dir: dir, df := ElioDateiFoo{lookUpDir: lookUpDir,
process: process, process: process,
} }
return &df return &df
@ -34,7 +37,7 @@ func NewElioDateiFoo(dir string, process ElioHandleFunc) *ElioDateiFoo {
// Veraltete Dateien mit Präfix no-import und Postifx .old benennen. // Veraltete Dateien mit Präfix no-import und Postifx .old benennen.
// Gültige Dateinamen zur Extraktion in Closure übergeben. // Gültige Dateinamen zur Extraktion in Closure übergeben.
func (f *ElioDateiFoo) ScanCsv() { func (f *ElioDateiFoo) ScanCsv() {
files, err := os.ReadDir(f.dir) files, err := os.ReadDir(f.lookUpDir)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -42,7 +45,7 @@ func (f *ElioDateiFoo) ScanCsv() {
filemap := make(map[string]filedata) filemap := make(map[string]filedata)
for _, file := range files { for _, file := range files {
if !strings.Contains(file.Name(), "csv") { if !strings.Contains(file.Name(), FileExt) {
continue continue
} }
tl, err := tools.ExtractDateAndConvertToDate(file.Name()) tl, err := tools.ExtractDateAndConvertToDate(file.Name())