Skip to content

Commit

Permalink
flag working in nm/st
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan-Zamfir committed Jun 10, 2024
1 parent b03ce1a commit fb0cb0f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
31 changes: 12 additions & 19 deletions cli/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,25 @@ var normalizeCmd = &cobra.Command{
cols = append(cols, result)
}

//var exportFilePath string
//log.Println(exportFilePath, "path")
//if exportFilePath == " " {
// log.Println("was nil")
// err = csvData.ToCSV(head, cols, "./DataNM.csv")
// if err != nil {
// log.Fatal(err)
// }
//}
//log.Println("Not empty???")
//err = csvData.ToCSV(head, cols, exportFilePath)
//if err != nil {
// log.Fatal(err)
//}

err = csvData.ToCSV(head, cols, "./DataNM.csv")
if err != nil {
log.Fatal(err)
if exportFilePath != "" {
err = csvData.ToCSV(head, cols, exportFilePath)
if err != nil {
log.Fatal(err)
}
} else {
err = csvData.ToCSV(head, cols, "./DataNM.csv")
if err != nil {
log.Fatal(err)
}
}

},
}

func init() {
var exportFilePath string

rootCmd.AddCommand(normalizeCmd)
normalizeCmd.Flags().StringVarP(&exportFilePath, "export", "e", "", "Export to filepath -> (provide path) | if empty -> ./DataNM.csv")
}

// go run . nm testdata.csv -e ../../Desktop/test.csv
21 changes: 14 additions & 7 deletions cli/standardise.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
)

var exportFilePath string

var standardiseCmd = &cobra.Command{
Use: "stand",
Short: "Will return standardised values as .csv file", //decide
Expand All @@ -26,18 +28,23 @@ var standardiseCmd = &cobra.Command{
result := <-c
cols = append(cols, result)
}

err = csvData.ToCSV(head, cols, "./DataST.csv")
if err != nil {
log.Fatal(err)
if exportFilePath != "" {
err = csvData.ToCSV(head, cols, exportFilePath)
if err != nil {
log.Fatal(err)
}
} else {
err = csvData.ToCSV(head, cols, "./DataST.csv")
if err != nil {
log.Fatal(err)
}
}

},
}

func init() {
var exportFilePath string

rootCmd.AddCommand(standardiseCmd)
standardiseCmd.Flags().StringVarP(&exportFilePath, "export", "e", "", "Export to filepath -> (provide path) | if empty -> ./DataST.csv")
}

// go run . stand testdata.csv -e ../../Desktop/test.csv

0 comments on commit fb0cb0f

Please sign in to comment.