Skip to content

Instantly share code, notes, and snippets.

@phette23
Created August 27, 2021 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phette23/7a999264a41e0a48407c763b6b0dd027 to your computer and use it in GitHub Desktop.
Save phette23/7a999264a41e0a48407c763b6b0dd027 to your computer and use it in GitHub Desktop.
create a CSV to populate NSO groups in Moodle > Upload Users
#!/usr/bin/env bash
# accepts three files that are just the copy-pasted email column from a Google Sheet
# some of the rows can be empty, also note that the course shortnames change year to year
FRESH=$1
GRAD=$2
TRSFR=$3
# delete empty lines, remove "cca.edu" from emails
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $FRESH
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $GRAD
sed -e '/^$/d' -e 's|@cca\.edu||' -i '.bak' $TRSFR
# add respective course and group to every line
sed -e 's|$|,NSO-FRESH-2021SU,"Freshman International"|' -i '.bak' $FRESH
sed -e 's|$|,NSO-GRAD-2021SU,"Graduate International"|' -i '.bak' $GRAD
sed -e 's|$|,NSO-TRSFR-2021SU,"Transfer International"|' -i '.bak' $TRSFR
# add header row
echo 'username,course1,group1' | cat - $FRESH $GRAD $TRSFR > users.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment