Q2a import error

AI-generated summary

Q2a import error

The user is experiencing an error when importing users using the Communiteq Q2A import script. The error occurs when the script tries to import users and encounters a nil value for the downcase method.

sat tried the official Q2A import script, but it never worked for them. pfaffman suggested updating to the latest version of the script, but noted that it doesn’t import passwords.

sat asked for help modifying the script to skip importing users with empty fields. pfaffman mentioned that extensive modifications are outside the scope of this discussion and suggested seeking professional help.

sat implemented a solution by adding a check for empty username and email fields, assigning default values if they are empty. pfaffman did not explicitly review the code, but sat reported that it worked.

I’m using [this q2a import](https://gist.github.com/[Communiteq](https://www.communiteq.com) (formerly DiscourseHosting)/769eff2014d5482f0ab776de03dc3349) script and see below error. Please help to fix this issue.

Is it problem with my userbase or script. How to fix. Thanks!

Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...

importing users
       80 / 447 ( 17.9%)  [208 items/min]  Traceback (most recent call last):
	12: from script/import_scripts/question2answer.rb:601:in `<main>'
	11: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
	10: from script/import_scripts/question2answer.rb:70:in `execute'
	 9: from script/import_scripts/question2answer.rb:89:in `import_users'
	 8: from /var/www/discourse/script/import_scripts/base.rb:877:in `batches'
	 7: from /var/www/discourse/script/import_scripts/base.rb:877:in `loop'
	 6: from /var/www/discourse/script/import_scripts/base.rb:878:in `block in batches'
	 5: from script/import_scripts/question2answer.rb:106:in `block in import_users'
	 4: from /var/www/discourse/script/import_scripts/base.rb:247:in `create_users'
	 3: from /var/www/discourse/script/import_scripts/base.rb:247:in `each'
	 2: from /var/www/discourse/script/import_scripts/base.rb:259:in `block in create_users'
	 1: from /var/www/discourse/script/import_scripts/base.rb:290:in `create_user'
/var/www/discourse/script/import_scripts/base.rb:393:in `find_existing_user': undefined method `downcase' for nil:NilClass (NoMethodError)

It looks like discourse/script/import_scripts/question2answer.rb at main · discourse/discourse · GitHub was updated more recently. (Oh, but it doesn’t import passwords).

Some field is empty or missing and shouldn’t be. You can try adding a put statement at line 111 printing out the user data and see if any of those fields are empty. And if they are, then you figure out why.

@pfaffman Thank you for the quick reply. appreciate your help.

official q2a import script never worked for me even for other q2a sites. Your script works well.

If some field is missing or empty, I’m Ok to not import that users, please let me know how to do that. which code line to modify.

btw, I’m not good at coding :frowning: I will just follow your instructions to modify code.
Thanks!

That’s beyond the scope of what can be done here. If you need more help, please see Redirecting… and let me know your needs.

@pfaffman I tired below solution at line 111 and it worked. Do you see issue with this code? I’m planning to delete all users with below email id/username after import.

Thanks again for your help!

        if !username
            username = "userempty"
        end

        if !email
            email = "test@example.com"
        end

        puts "username: #{username}"
        puts "email: #{email}"