Problem with csv upload and User Profile Fields

Problem with csv upload and User Profile Fields

by Adrian Norman -
Number of replies: 17
Hello, I've had a look around and seen others with the same problem but can't find a solution.

I have created a new user profile field: Enrolment ID 01, so the short name for this field is (according to the documentation): profile_field_enrolid01

AND...
in the csv file i have created a field name with the short name: profile_field_enrolid01

but when i try to import users with this new field, moodle tells me it is not a valid field name.

i think i am following the rules and can't work out what i am doing wrong.

can anyone help?

cheers!
adrian



Average of ratings: -
In reply to Adrian Norman

Re: Problem with csv upload and User Profile Fields

by John White -
Adrian,

But does enrolid01 match EXACTLY the shortname you have in your User Profile Fields definition, at...
Administration->Users->Accounts->User Profile Fields ?

No spaces, no capitals, no funny punctuation (except _ )?

Or have you given it a shortname (in User Profile Fields) of profile_field_enrolid01, in which case the import file would require a column heading: profile_field_profile_field_enrolid01!!!

Regards,

John
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Adrian Norman -
hi john,

thanks for your post. but i am still vexed by this problem.

i've changed the User Profile Field to just the short name in Administration>Accounts>User Profile Fields. It is now: enrolid01 (previously it was profile_field_enrolid1)

and in the import file the column heading is: profile_field_enrolid01

and there is no funny punctuation there, exactly as i wrote it there.


BUT when i try to import the CSV file, Moodle complains "profile_field_enrolid01 is not a valid field name."

i'm stumped! i must be doing something wrong but i can't work out what it is.

adrian


In reply to Adrian Norman

Re: Problem with csv upload and User Profile Fields

by John White -
Adrian,

I agree its vexing.

But (just in case) look again at your last post, what you typed is not what you meant. 1? 01?

Check your settings again.

Regards,

John
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Adrian Norman -
hmmm.. i'm almost there. you were right, in my tiredness i had made a 'clerical' error in copying the profile field short name in the Admin area to the csv file.. hence the invalid profile field error.

so i corrected the CSV file with the correct shortname (plus profile_field at the beginning) and success! yay! i've managed to populate the enrol1 profile field by importing the csv file in my first test.

then, i added three more profile fields (enrol2, enrol3 and dob) just to test. it preprocesses fine and it looks like it's accepting the new profile fields and populating the values etc.

but when i look at the profile of the test account, the data has not populated those new profile fields (enrol2, enrol3 and dob).

i wonder if it is a bit glitchy.... or maybe it's me. is there a limit to the number of new profile fields you can set up?

adrian
In reply to Adrian Norman

Re: Problem with csv upload and User Profile Fields

by John White -
Adrian,

Are you now certain that you have not got the same problem with 02, 03?

And dob is a classic, because it wont import DoB (or, I think, d o b, or d.o.b)

Or have you now got data that is stalling the import? Again dob could be a problem - just possibly - leave that one off and try again?

Good luck,

John
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Sophia Danesino -
I've the same problem with Moodle 1.8.4.
1. I have created a new user profile field with the short name class (no capital letters or spaces),
2. in the csv file I have created a field name with the short name: profile_field_class
When i try to import users with this new field, moodle tells me it is not a valid field name.
Can anyone help me?
Thank you
Sophia
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by John White -
Sophia,

There is a very slim chance that the problem is actually with the word 'class' because it is a reserved word in PHP code.
Try 'myclass' and 'profile_field_myclass' just to see if that removes the problem.

Regards,

John
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Sophia Danesino -
Unfortunately it doesn't work. In the attached file there is an example of my csv. Thanks you a lot.
Sophia
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by John White -
Sophia,

Very good idea attaching the file snippet.
I think you have been tricked into thinking the problem is with the first profile_field name, when it is not!
You can only use the course1 field if it is followed by role1 like this

username,course1,role1,course2,role2
un000,Seminars,student,Lessons,student

To push users into a course you must define their role in that course using the shortname of the role. So your import is expecting a role field next!

If in doubt, put the course/role assignments in a separate CSV with just the username as the key, as shown above.

Regards,

John
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Sophia Danesino -
I deleted the course1 field from the csv, but the message is the same. I also added the field role1 to my csv but I got the same result.
I receive an error message on the first profle_field name.
Hope this ccan help.
Sophia
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by John White -
Sophia,

I'm definitely running out of idea on this one!
I even checked the Tracker to see if there was a bug reported on this one - there were a lots of bugs reported but I did not find specifically this one for 1.8.4.

I would try putting only one profile_field at the end of the test list (just to try narrowing down the problem). Try one of the other fields. Which field type did you selected for each field? Does the simple TextArea type work? Some bugs were reported on 'menu' and 'checkbox' types.

I'm sure that you have checked very carefully that the shortname of the added field is just XXXX when you upload profile_field_XXXX.


I hope we can narrow this down.

Regards,

John

In reply to John White

Re: Problem with csv upload and User Profile Fields

by Sophia Danesino -
I tried to specify only a simple TextArea field at the end of the CSV, but I get the same error. Can you suggest me a workaround? Do you have a script to insert the data into the mdl_user_info_data table? I really have a lot of data, I cannot do it by hand.

Thank you
Sophia
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by Sophia Danesino -
I upgraded my Moodle to 1.9.4 and the upload worked. Thank you anyway.
Sophia
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by John White -
Sophia,

I was just about to say... I think you've got a bug... upgrade! smile

Well done.

John
In reply to Sophia Danesino

Re: Problem with csv upload and User Profile Fields

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Sophia - If you think this is a bug in Moodle 1.8, please create an issue in the tracker and let me know so that I can take a look at it. If you have a sample csv file that you can attach to the issue that would help me to re-create the situation. If it is in fact a 1.8 bug, I would like to see it get fixed. Let me know how I can be of help. Peace - Anthony
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Vivek Sharma -
ohhhhhhhh great, i got solution from this discussion. smile
In reply to John White

Re: Problem with csv upload and User Profile Fields

by Sharon R -

I've been trying to work out this problem all day, but just found something simple that worked with my CSV. I highlighted all the text and THEN clicked Save. I changed nothing else.

Then I uploaded this saved file... and it worked. I don't know if this is a random thing, or if this is actually my problem.