From 7408024e391dd82633b5699d01168fec2794dc71 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 22 Oct 2023 17:05:18 -0700 Subject: [PATCH] Updating based on error --- pkg/airport/parsers/csv/csv.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/airport/parsers/csv/csv.go b/pkg/airport/parsers/csv/csv.go index 56165a5..39a9ab0 100644 --- a/pkg/airport/parsers/csv/csv.go +++ b/pkg/airport/parsers/csv/csv.go @@ -45,20 +45,17 @@ func (p *Parser) Parse() ([]airport.Airport, error) { return nil, fmt.Errorf("unable to read csv data - %w", err) } - // Iterate over the CSV records - for _, r := range rec { - // Convert the record to an Airport - a, err := RecordToAirport(r) - if err != nil { - // Skip headers and records with not enough fields - if err == ErrIsHeader || err == ErrNotEnoughFields { - continue - } - return nil, fmt.Errorf("unable to convert record to airport - %w", err) + // Convert the record to an Airport + a, err := RecordToAirport(rec) + if err != nil { + // Skip headers and records with not enough fields + if err == ErrIsHeader || err == ErrNotEnoughFields { + continue } - // Append the Airport to the slice - airports = append(airports, a) + return nil, fmt.Errorf("unable to convert record to airport - %w", err) } + // Append the Airport to the slice + airports = append(airports, a) } // Return the slice of Airports