Added missing elements to CSV output

pull/2/head
Jean-Marc Meessen 4 years ago
parent eec547e704
commit c8ed5cc86a

@ -1,4 +1,4 @@
package cmd package cmd
//VersionString is the version that will be displayed with the -v switch //VersionString is the version that will be displayed with the -v switch
const VersionString = "v0.0.0.0-8-gda680bc (2020-07-15)" const VersionString = "v0.0.0.0-12-geec547e (2020-07-16)"

@ -42,15 +42,25 @@ func buildCsv(fullLog []LogLine) (csvList []string) {
for _, logLine := range fullLog { for _, logLine := range fullLog {
var csvLine strings.Builder var csvLine strings.Builder
csvLine.WriteString("V2,") csvLine.WriteString("V2,")
csvLine.WriteString(fmt.Sprintf("%s,", logLine.MyCall)) csvLine.WriteString(fmt.Sprintf("%s", logLine.MyCall))
csvLine.WriteString(fmt.Sprintf("%s,", logLine.MySOTA)) csvLine.WriteString(fmt.Sprintf(",%s", logLine.MySOTA))
csvLine.WriteString(fmt.Sprintf("%s,", csvDate(logLine.Date))) csvLine.WriteString(fmt.Sprintf(",%s", csvDate(logLine.Date)))
csvLine.WriteString(fmt.Sprintf("%s,", logLine.Time)) csvLine.WriteString(fmt.Sprintf(",%s", logLine.Time))
//TODO: Should we test the result //TODO: Should we test the result
_, _, _, sotaBand := IsBand(logLine.Band) _, _, _, sotaBand := IsBand(logLine.Band)
csvLine.WriteString(fmt.Sprintf("%s,",sotaBand )) csvLine.WriteString(fmt.Sprintf(",%s",sotaBand ))
csvLine.WriteString(fmt.Sprintf("%s,",logLine.Mode)) csvLine.WriteString(fmt.Sprintf(",%s",logLine.Mode))
csvLine.WriteString(fmt.Sprintf("%s", logLine.Call)) csvLine.WriteString(fmt.Sprintf(",%s", logLine.Call))
if logLine.SOTA != "" {
csvLine.WriteString(fmt.Sprintf(",%s", logLine.SOTA))
} else {
if logLine.Comment != "" {
csvLine.WriteString(",")
}
}
if logLine.Comment != "" {
csvLine.WriteString(fmt.Sprintf(",%s", logLine.Comment))
}
csvList = append(csvList, csvLine.String()) csvList = append(csvList, csvLine.String())
} }

@ -34,10 +34,11 @@ func Test_buildCsv(t *testing.T) {
{MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM", Nickname: "ONFF-0259-1"}, {MyCall: "ON4KJM/P", Call: "S57LC", Date: "2020-05-24", Time: "1310", Band: "20m", Frequency: "14.045", Mode: "CW", RSTsent: "599", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM", Nickname: "ONFF-0259-1"},
{MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM"}, {MyCall: "ON4KJM/P", Call: "ON4LY", Date: "2020-05-24", Time: "1312", Band: "20m", Mode: "CW", RSTsent: "559", RSTrcvd: "599", MySOTA: "ON/ON-001", Operator: "ON4KJM"},
} }
//add case with no SOTA and with or no comment
expectedOutput1 := []string{ expectedOutput1 := []string{
"V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14Mhz,CW,S57LC", "V2,ON4KJM/P,ON/ON-001,24/05/20,1310,14MHz,CW,S57LC",
"V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14Mhz,CW,ON4LY", "V2,ON4KJM/P,ON/ON-001,24/05/20,1312,14MHz,CW,ON4LY",
} }
type args struct { type args struct {

@ -122,35 +122,35 @@ func IsBand(inputStr string) (result bool, lowerLimit, upperLimit float64, altBa
case "560m": case "560m":
return true, 0.501, 0.504, "tbd" return true, 0.501, 0.504, "tbd"
case "160m": case "160m":
return true, 1.8, 2.0, "1.8Mhz" return true, 1.8, 2.0, "1.8MHz"
case "80m": case "80m":
return true, 3.5, 4.0, "3.5Mhz" return true, 3.5, 4.0, "3.5MHz"
case "60m": case "60m":
return true, 5.06, 5.45, "5Mhz" return true, 5.06, 5.45, "5MHz"
case "40m": case "40m":
return true, 7.0, 7.3, "7Mhz" return true, 7.0, 7.3, "7MHz"
case "30m": case "30m":
return true, 10.1, 10.15, "10Mhz" return true, 10.1, 10.15, "10MHz"
case "20m": case "20m":
return true, 14.0, 14.35, "14Mhz" return true, 14.0, 14.35, "14MHz"
case "17m": case "17m":
return true, 18.068, 18.168, "18Mhz" return true, 18.068, 18.168, "18MHz"
case "15m": case "15m":
return true, 21.0, 21.45, "21Mhz" return true, 21.0, 21.45, "21MHz"
case "12m": case "12m":
return true, 24.890, 24.99, "24Mhz" return true, 24.890, 24.99, "24MHz"
case "10m": case "10m":
return true, 28.0, 29.7, "28Mhz" return true, 28.0, 29.7, "28MHz"
case "6m": case "6m":
return true, 50, 54, "50Mhz" return true, 50, 54, "50MHz"
case "4m": case "4m":
return true, 70, 71, "70Mhz" return true, 70, 71, "70MHz"
case "2m": case "2m":
return true, 144, 148, "144Mhz" return true, 144, 148, "144MHz"
case "1.25m": case "1.25m":
return true, 222, 225, "222Mhz" return true, 222, 225, "222MHz"
case "70cm": case "70cm":
return true, 420, 450, "432Mhz" return true, 420, 450, "432MHz"
case "33cm": case "33cm":
return true, 902, 928, "tbd" return true, 902, 928, "tbd"
case "23cm": case "23cm":

@ -288,12 +288,12 @@ func TestIsBand(t *testing.T) {
{ {
"valid band", "valid band",
args{inputStr: "40m"}, args{inputStr: "40m"},
true, 7.0, 7.3, "7Mhz", true, 7.0, 7.3, "7MHz",
}, },
{ {
"valid band but uppercase", "valid band but uppercase",
args{inputStr: "40M"}, args{inputStr: "40M"},
true, 7.0, 7.3,"7Mhz", true, 7.0, 7.3,"7MHz",
}, },
} }
for _, tt := range tests { for _, tt := range tests {

Loading…
Cancel
Save