Updating tables with bulk of data through CSV
You can use first_or_initialize and first_or_create! to skip the if...else statementes. 

location = Location.where(name: 'New York').first_or_create! do |loc| 
  loc.short_name = 'NY'
  loc.status     = 'Active'
end

discipline = Discipline.where(name: 'Name', location_id: location.id).first_or_initialize
discipline.assign_attributes code: 'code', status: 'Active'
discipline.save!

speciality = Speciality.where(name: 'Name', location_id: location.id).first_or_initialize
speciality.assign_attributes code: 'code', discipline_id, discipline.id
speciality.save!