-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
46 lines (39 loc) · 997 Bytes
/
Copy pathapp.go
File metadata and controls
46 lines (39 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package csv_cli_tool
import "fmt"
const defaultOutput = "out"
const defaultInput = "in"
const defaultTrackingFileName = "log.txt"
const defaultHeaderCSV = "header.csv"
const defaultStartRow = -1
const defaultEndRow = -1
func App(headerFile string, input string, outputFolder string, trackingFileName string, startRow int, endRow int) (err error) {
if input == "" {
input = defaultInput
}
if outputFolder == "" {
outputFolder = defaultOutput
}
if trackingFileName == "" {
trackingFileName = defaultTrackingFileName
}
if headerFile == "" {
headerFile = defaultHeaderCSV
}
if startRow < 1 {
startRow = defaultStartRow
}
if endRow < 1 {
endRow = defaultEndRow
}
head, err := getHead(headerFile)
if err != nil {
return err
}
fmt.Println("Got header: ", head)
files, err := getCSVFileOrFilesInPath(input, startRow, endRow)
if err != nil {
return err
}
fmt.Println("Got files: ", files)
return mergeHeadWithFiles(head, files, outputFolder, trackingFileName)
}