mirror of
https://github.com/idanoo/NZCovidBot
synced 2025-07-01 11:12:15 +00:00
Add safetychecks for invalid rows
This commit is contained in:
parent
ceabee4531
commit
2e61500e73
1 changed files with 9 additions and 0 deletions
|
@ -46,6 +46,11 @@ func parseCsvRow(data string) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(c) < 6 {
|
||||
log.Printf("Invalid line. Skipping")
|
||||
return
|
||||
}
|
||||
|
||||
if rowHasChanged(c[4], st, et, c[2], c[3]) {
|
||||
newRow := UpdatedRow{
|
||||
FromDate: st,
|
||||
|
@ -246,6 +251,10 @@ func parseRawRowData(data string) ([]string, time.Time, time.Time, error) {
|
|||
|
||||
c := make([]string, 0)
|
||||
c = append(c, fields...)
|
||||
if len(c) < 6 {
|
||||
// Add helper in case someone somehow does something wrong
|
||||
return output, time.Now(), time.Now(), err
|
||||
}
|
||||
|
||||
st, et, err := parseRowTimes(c[4], c[5])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue