Csv Extension in Konstante ausgelagert.
This commit is contained in:
parent
531bb5ba41
commit
bf86ab9c83
|
|
@ -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
|
||||||
|
|
@ -17,12 +19,13 @@ type filedata struct {
|
||||||
type ElioHandleFunc func(filename string) bool
|
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())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue