Skip to content

Instantly share code, notes, and snippets.

@gabriel4649
Last active January 26, 2018 21:42
Show Gist options
  • Save gabriel4649/080eba11880b9b82b85602a110b88bdd to your computer and use it in GitHub Desktop.
Save gabriel4649/080eba11880b9b82b85602a110b88bdd to your computer and use it in GitHub Desktop.
Get list of Canvas sortable names
import csv
from canvasapi import Canvas
CANVAS_API_URL = ''
CANVAS_TOKEN = ''
COURSE_ID = 9999 # int class id
def get_canvas_client():
return Canvas(CANVAS_API_URL,
CANVAS_TOKEN)
def export_student_data():
canvas = get_canvas_client()
course = canvas.get_course(COURSE_ID)
students = course.get_users(enrollment_type=['student'], include=['email'], per_page=500)
for student in students:
sortable_name = student.sortable_name.replace(',', '') # Remove names
sortable_name = sortable_name.replace(' ', '') # Remove spaces
sortable_name = sortable_name.replace('-', '') # Remove hyphens
print(sortable_name.lower() + ', ' + student.login_id + '@gatech.edu')
export_student_data()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment