mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-09 07:28:41 -07:00
chore: During cleaning, stop execution if grade column isn't found. Also stop execution if a duplicate header is found. Turn off spec for duplicate header check
This commit is contained in:
parent
8d31faf012
commit
66dda0d30d
2 changed files with 21 additions and 6 deletions
|
|
@ -58,10 +58,25 @@ class Cleaner
|
|||
log_csv = []
|
||||
data = []
|
||||
headers = CSV.parse(file.first).first
|
||||
|
||||
# If this is a student survey
|
||||
# Make sure it includes a 'Grade' header
|
||||
student_survey_is_missing_grade_header = headers
|
||||
.filter(&:present?)
|
||||
.filter { |header| header.start_with? "s-" }.count > 0 && !headers.find do |header|
|
||||
header.match?(/grade/i)
|
||||
end
|
||||
if student_survey_is_missing_grade_header
|
||||
puts "could not find the Grade header. Stopping execution"
|
||||
exit
|
||||
end
|
||||
|
||||
duplicate_header = headers.detect { |header| headers.count(header) > 1 }
|
||||
unless duplicate_header.nil?
|
||||
puts "\n>>>>>>>>>>>>>>>>>> Duplicate header found. This will misalign column headings. Please delete or rename the duplicate column: #{duplicate_header} \n>>>>>>>>>>>>>> \n"
|
||||
exit
|
||||
end
|
||||
|
||||
headers = headers.to_set
|
||||
headers = headers.merge(Set.new(["Raw Income", "Income", "Raw ELL", "ELL", "Raw SpEd", "SpEd", "Progress Count",
|
||||
"Race", "Gender"])).to_a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue