# Q2a import error

**URL:** https://meta.discourse.org/t/q2a-import-error/130063
**Category:** Migration
**Created:** [October 2, 2019, 6:18pm UTC](https://meta.discourse.org/t/q2a-import-error/130063 "2019-10-02T18:18:18Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [October 2, 2019, 6:18pm UTC](https://meta.discourse.org/t/q2a-import-error/130063/1 "2019-10-02T18:18:18Z")

</div>

I’m using [this q2a import]([https://gist.github.com/[Communiteq](https://www.communiteq.com)](https://gist.github.com/%5BCommuniteq%5D(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!

```plaintext
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)

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 2, 2019, 6:39pm UTC](https://meta.discourse.org/t/q2a-import-error/130063/2 "2019-10-02T18:39:16Z")

</div>

It looks like [discourse/script/import\_scripts/question2answer.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/script/import_scripts/question2answer.rb) 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.

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [October 2, 2019, 6:49pm UTC](https://meta.discourse.org/t/q2a-import-error/130063/3 "2019-10-02T18:49:20Z")

</div>

@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 ☹ I will just follow your instructions to modify code.  
Thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 2, 2019, 7:04pm UTC](https://meta.discourse.org/t/q2a-import-error/130063/4 "2019-10-02T19:04:01Z")

</div>

That’s beyond the scope of what can be done here. If you need more help, please see [Redirecting…](https://www.literatecomputing.com/discourse-migration/) and let me know your needs.

---

<div class="post-metadata">

### Author: ![sat](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sat](https://meta.discourse.org/u/sat)
#### Post date: [October 3, 2019, 1:50am UTC](https://meta.discourse.org/t/q2a-import-error/130063/5 "2019-10-03T01:50:39Z")

</div>

@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!

```plaintext
        if !username
            username = "userempty"
        end

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

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

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 2, 2019, 2:04am UTC](https://meta.discourse.org/t/q2a-import-error/130063/6 "2019-11-02T02:04:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
