53 lines
1.9 KiB
Go
53 lines
1.9 KiB
Go
package meteo
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
type H map[string]any
|
|
|
|
type MeteoData struct {
|
|
Timestamp time.Time `csv:"fecha"`
|
|
Location string `csv:"ciudad"`
|
|
MaxTemp float32 `csv:"temperatura maxima"`
|
|
MinTemp float32 `csv:"temperatura minima"`
|
|
Rainfall float32 `csv:"precipitacion"`
|
|
Cloudiness float32 `csv:"nubosidad"`
|
|
}
|
|
|
|
type RejectedMeteoData struct {
|
|
RowValue string
|
|
Reason string
|
|
}
|
|
|
|
type FileStats struct {
|
|
RowsInserted int `json:"rows_inserted"`
|
|
RowsRejected int `json:"rows_rejected"`
|
|
ElapsedMS int `json:"elapsed_ms"`
|
|
FileChecksum string `json:"file_checksum"`
|
|
}
|
|
|
|
var (
|
|
ErrCannotParseFile = errors.New("cannot parse file")
|
|
ErrValidateRecord = errors.New("error validating record")
|
|
ErrRecordNotValid = errors.New("record not valid")
|
|
ErrInvalidDateFormat = errors.New("invalid date format")
|
|
ErrReadingCSVHeader = errors.New("error reading CSV header")
|
|
ErrReadingCSVRow = errors.New("error reading CSV row")
|
|
ErrMissingDateField = errors.New("missing date field")
|
|
ErrMissingCityField = errors.New("missing city field")
|
|
ErrMissingMaxTempField = errors.New("missing max temp field")
|
|
ErrMissingMinTempField = errors.New("missing min temp field")
|
|
ErrMissingRainfallField = errors.New("missing rainfall field")
|
|
ErrMissingCloudinessField = errors.New("missing cloudiness field")
|
|
ErrInvalidMaxTemp = errors.New("invalid max temp")
|
|
ErrInvalidMinTemp = errors.New("invalid min temp")
|
|
ErrInvalidRainfall = errors.New("invalid rainfall")
|
|
ErrInvalidCloudiness = errors.New("invalid cloudiness")
|
|
ErrMaxTempOutOfRange = errors.New("max temp out of range (must be <= 60°C)")
|
|
ErrMinTempOutOfRange = errors.New("min temp out of range (must be >= -20°C)")
|
|
ErrRainfallOutOfRange = errors.New("rainfall out of range (must be 0-500 mm)")
|
|
ErrCloudinessOutOfRange = errors.New("cloudiness out of range (must be 0-100%)")
|
|
)
|