Skip to content

Commit

Permalink
Use CSV col 0 if not specified otherwise.
Browse files Browse the repository at this point in the history
Fixes the zero col usage problem on the same go.
  • Loading branch information
Jeewes committed Jan 9, 2020
1 parent 044caf4 commit 81efb6d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions nerc.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,16 @@ func toPriceString(price interface{}) (string, error) {
func writeConf(row []string, template string, i int, nercConf NercConf) {
templateVars := make(map[string]interface{})
for _, variable := range nercConf.Variables {
if variable.CSVSourceCol > 0 {
value := string(row[variable.CSVSourceCol])
//templateVars[variable.Key] = row[variable.CSVSourceCol]
if variable.Type == "price" && value != "" {
price, err := toPriceString(value)
if err != nil {
fmt.Println("Error in sku " + row[0] + ": " + err.Error())
} else {
value = price
}
value := string(row[variable.CSVSourceCol])
if variable.Type == "price" && value != "" {
price, err := toPriceString(value)
if err != nil {
fmt.Println("Error in sku " + row[0] + ": " + err.Error())
} else {
value = price
}
templateVars[variable.Key] = value
}
templateVars[variable.Key] = value
}
conf := ProcessFile(template, templateVars)
outputFile := "sku_" + row[0] + "_version_" + strconv.Itoa(i) + ".json"
Expand Down

0 comments on commit 81efb6d

Please sign in to comment.