I think I re-developed what you need. I had done this some time ago for version 1.9 but just redid it for 3.1.
You simply drop the attached file in the admin/tool/uploaduser directory. There are then 2 variables inside the script that you need to set.
$customfileLocation = "$CFG->dataroot/moodleimport/userimport.csv";
$defaultdomain = "@yourdomain.com";
The first is where your csv file sits. Mine is a mount inside the moodledata folder that the csv is dropped into automatically from our student management system (DASL) each night. The file conforms to the same format as the manual userupload in Moodle and the file is simply an edited version of that (from 3.1).
The second variable is for uploads without email fields. It will automatically make all new user emails username@yourdomain.com so that the upload functions without emails. This is the same as putting %u@yourdomain.com in the manual upload.
I then make this a nightly CRON job on my system.
I have been using this system for years. Automatically makes and updates existing users, adds them to correct course, and into the correct groups. Makes everything hands off once the courses are in Moodle.
Hope that helps!
I
would add this as a upload but the upload feature does not allow me to
upload something without it being a full mod, which this is obviously
not, since it is a single file.
Brian