Scrape latest data from DESE

This commit is contained in:
rebuilt 2022-12-20 15:26:11 -08:00
parent 4d5143964b
commit 7b9abe3793
16 changed files with 65000 additions and 5221 deletions

View file

@ -33,7 +33,9 @@ module Dese
submit_id = 'btnViewReport'
calculation = lambda { |headers, items|
percent_graduated_index = headers['All Grades'] - 1
return 'NA' if items[percent_graduated_index] == '' || items[percent_graduated_index].strip == '.0'
if items[percent_graduated_index].nil? || items[percent_graduated_index] == '' || items[percent_graduated_index].strip == '.0'
return 'NA'
end
percent_passing = items[percent_graduated_index].to_f
benchmark = 77.5

View file

@ -4,7 +4,13 @@ require 'csv'
# TODO: convert this to simpler format and add a run_all method
module Dese
class FourDOne
attr_reader :filepath
def initialize(filepath: Rails.root.join('data', 'admin_data', 'dese', '4D_1_plans_of_grads.csv'))
@filepath = filepath
end
def run_all
url = 'https://profiles.doe.mass.edu/statereport/plansofhsgrads.aspx'
browser = Watir::Browser.new
write_headers(filepath:)
@ -32,7 +38,7 @@ module Dese
def write_headers(filepath:)
CSV.open(filepath, 'w') do |csv|
headers = ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year','School Name', 'DESE ID', '4 Year Private College', '4 Year Public College', '2 Year Private College', '2 Year Public College',
headers = ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID', '4 Year Private College', '4 Year Public College', '2 Year Private College', '2 Year Public College',
'Other Post Secondary', 'Apprenticeship', 'Work', 'Military', 'Other', 'Unknown', 'Total']
csv << headers
end

View file

@ -1,9 +1,15 @@
require 'watir'
require 'csv'
# TODO convert this to simpler format and add a run_all method
# TODO: convert this to simpler format and add a run_all method
module Dese
class OneAOne
attr_reader :filepath
def initialize(filepath: Rails.root.join('data', 'admin_data', 'dese', '1A_1_teacher_data.csv'))
@filepath = filepath
end
def run_all
url = 'https://profiles.doe.mass.edu/statereport/teacherdata.aspx'
browser = Watir::Browser.new
write_headers(filepath:)