This commit is contained in:
Florian Brinker 2019-11-07 23:16:09 +01:00
commit 4c5f0018b3
5 changed files with 57 additions and 0 deletions

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module fbrinker/job-visualizer
go 1.13
require github.com/jinzhu/configor v1.1.1

7
go.sum Normal file
View File

@ -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=

BIN
job-visualizer Executable file

Binary file not shown.

42
main.go Normal file
View File

@ -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])
}
}
}

3
test.csv Normal file
View File

@ -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
1 2019-01-01 00:00:00 2019-01-01 00:08:00 echo Hello
2 2019-01-03 01:05:00 2019-01-03 03:14:00 echo Ola
3 2019-01-03 01:07:00 2019-01-03 12:45:00 echo Aloah