commit 4c5f0018b382744f6b5aed24130e430ef116f648 Author: Florian Brinker Date: Thu Nov 7 23:16:09 2019 +0100 init diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d785678 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module fbrinker/job-visualizer + +go 1.13 + +require github.com/jinzhu/configor v1.1.1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..226e66d --- /dev/null +++ b/go.sum @@ -0,0 +1,7 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/jinzhu/configor v1.1.1 h1:gntDP+ffGhs7aJ0u8JvjCDts2OsxsI7bnz3q+jC+hSY= +github.com/jinzhu/configor v1.1.1/go.mod h1:nX89/MOmDba7ZX7GCyU/VIaQ2Ar2aizBl2d3JLF/rDc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/job-visualizer b/job-visualizer new file mode 100755 index 0000000..61a08f4 Binary files /dev/null and b/job-visualizer differ diff --git a/main.go b/main.go new file mode 100644 index 0000000..58fea36 --- /dev/null +++ b/main.go @@ -0,0 +1,42 @@ +package main + +import ( + "bufio" + "encoding/csv" + "flag" + "fmt" + "io" + "os" +) + +func main() { + var file = flag.String("file", "", "File to import") + var columnStart = flag.Int("columnStart", -1, "Column number with a start Datetime") + var columnEnd = flag.Int("columnEnd", -1, "Column number with a end Datetime") + var descriptiveColumn = flag.Int("columnDescription", -1, "Column number with a descriptive name or similar") + flag.Parse() + + if _, err := os.Stat(*file); os.IsNotExist(err) || *columnStart == -1 || *columnEnd == -1 || *descriptiveColumn == -1 { + flag.Usage() + return + } + + fmt.Println("Scanning file " + *file + "...") + readCsvFile(*file, *columnStart, *columnEnd, *descriptiveColumn) +} + +func readCsvFile(csvFile string, columnStart int, columnEnd int, descriptiveColumn int) { + f, _ := os.Open(csvFile) + r := csv.NewReader(bufio.NewReader(f)) + + for { + record, err := r.Read() + if err == io.EOF { + break + } + + for value := range record { + fmt.Printf(" %v\n", record[value]) + } + } +} diff --git a/test.csv b/test.csv new file mode 100644 index 0000000..09ce20a --- /dev/null +++ b/test.csv @@ -0,0 +1,3 @@ +2019-01-01 00:00:00,2019-01-01 00:08:00,echo Hello +2019-01-03 01:05:00,2019-01-03 03:14:00,echo Ola +2019-01-03 01:07:00,2019-01-03 12:45:00,echo Aloah \ No newline at end of file