Importing User Text File Problems

Importing User Text File Problems

by David Marosek -
Number of replies: 5
Hi, I'm trying to import a tab delimited text file into Moodle with a large list of users. I started the file in Excel to modify it so the fields match what Moodle needs to import. When I run the import I get an error that states, ""last name" is not a valid field name", even tho when i look at the text file it shows the last name fields as "Last name" which is how it looks in Moodle.

Does anyone have any suggestion on what the problem might be? I'm using version 1.9.3.

Thanks!
Average of ratings: -
In reply to David Marosek

Re: Importing User Text File Problems

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It isn't... it's 'lastname'.

Some more... firstname, lastname, email, etc.

You can get the whole list from the user database table definition:


+---------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------+------+-----+---------+----------------+
| id | bigint(10) unsigned | NO | PRI | NULL | auto_increment |
| auth | varchar(20) | NO | MUL | manual | |
| confirmed | tinyint(1) | NO | MUL | 0 | |
| policyagreed | tinyint(1) | NO | | 0 | |
| deleted | tinyint(1) | NO | MUL | 0 | |
| mnethostid | bigint(10) unsigned | NO | MUL | 0 | |
| username | varchar(100) | NO | | | |
| password | varchar(32) | NO | | | |
| idnumber | varchar(255) | NO | MUL | | |
| firstname | varchar(100) | NO | MUL | | |
| lastname | varchar(100) | NO | MUL | | |
| email | varchar(100) | NO | MUL | | |
| emailstop | tinyint(1) unsigned | NO | | 0 | |
| icq | varchar(15) | NO | | | |
| skype | varchar(50) | NO | | | |
| yahoo | varchar(50) | NO | | | |
| aim | varchar(50) | NO | | | |
| msn | varchar(50) | NO | | | |
| phone1 | varchar(20) | NO | | | |
| phone2 | varchar(20) | NO | | | |
| institution | varchar(40) | NO | | | |
| department | varchar(30) | NO | | | |
| address | varchar(70) | NO | | | |
| city | varchar(20) | NO | MUL | | |
| country | varchar(2) | NO | MUL | | |
| lang | varchar(30) | NO | | en_utf8 | |
| theme | varchar(50) | NO | | | |
| timezone | varchar(100) | NO | | 99 | |
| firstaccess | bigint(10) unsigned | NO | | 0 | |
| lastaccess | bigint(10) unsigned | NO | MUL | 0 | |
| lastlogin | bigint(10) unsigned | NO | | 0 | |
| currentlogin | bigint(10) unsigned | NO | | 0 | |
| lastip | varchar(15) | NO | | | |
| secret | varchar(15) | NO | | | |
| picture | tinyint(1) | NO | | 0 | |
| url | varchar(255) | NO | | | |
| description | text | YES | | NULL | |
| mailformat | tinyint(1) unsigned | NO | | 1 | |
| maildigest | tinyint(1) unsigned | NO | | 0 | |
| maildisplay | tinyint(2) unsigned | NO | | 2 | |
| htmleditor | tinyint(1) unsigned | NO | | 1 | |
| ajax | tinyint(1) unsigned | NO | | 1 | |
| autosubscribe | tinyint(1) unsigned | NO | | 1 | |
| trackforums | tinyint(1) unsigned | NO | | 0 | |
| timemodified | bigint(10) unsigned | NO | | 0 | |
| trustbitmask | bigint(10) unsigned | NO | | 0 | |
| imagealt | varchar(255) | YES | | NULL | |
| screenreader | tinyint(1) | NO | | 0 | |
+---------------+---------------------+------+-----+---------+----------------+
In reply to Howard Miller

Re: Importing User Text File Problems

by David Marosek -
Oh, ok! I was going by what I was seeing on the actual Moodle screen.

Thanks! I'm going to copy and keep this list. smile
In reply to David Marosek

Re: Importing User Text File Problems

by David Marosek -
Another question regarding the import file. I made the changes to the field names, but now I also have two other fields that I added to the user profile: Job Title and Employee Status.

I changed the names in the text file to jobtitle and employeestatus, but I'm getting the same error as before for these fields. Is there a way to get these two fields to import with the standard fields, or do they have to be added after the fact?

Thanks again!
In reply to David Marosek

Re: Importing User Text File Problems

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

You must append profile_field_ to each of the profile field short names in the first line of the import file. Example, in the User Profile Fields you have two fields:

Short Name: jobtitle
Name: Job Title

Short Name: employeestatus
Name: Employee Status

Use this format in your import file:

id,username,firstname,lastname,profile_field_jobtitle,profile_field_employeestatus
1,jon123,Jon,Doe,teacher,active
2,mary456,Mary,Loo,teacher,fired
3,fred111,Fred,Smith,teacher,active