# עדכון פרטי משתמשים בכמות גדולה

**URL:** <https://meta.discourse.org/t/update-user-information-in-bulk/220271>\
**Category:** Product Support\
**Created:** [7 במרץ,‏ 2022,‏ 11:57am UTC](https://meta.discourse.org/t/update-user-information-in-bulk/220271 "2022-03-07T11:57:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [7 במרץ,‏ 2022,‏ 2:18pm UTC](https://meta.discourse.org/t/update-user-information-in-bulk/220271/2 "2022-03-07T14:18:23Z")

</div>

The best way is probably with the API, though you could also do it with a script that would read your CSV and update it in rails.

Here’a rake task that updates custom user fields that could be modified to update other stuff:

```ruby

require "csv"
desc "Import user fields"
task "user_fields:import_csv", [:filename] => [:environment] do |_, args|
  puts "Filename: #{args[:filename]}"
  data = CSV.read(args[:filename], headers: true );
  data.each_entry do |row|
    puts "doing row."
    row.to_h.each do |x|
      user_id = row['user_id']
      if x.first == 'user_id'
        u = User.find(user_id)
        puts "Got user: #{u.username}"
      else
        name = x.first
        val = row[x.first]
        ucf = UserCustomField.find_by(user_id: row['user_id'], name: name)
        if ucf
          if val != ucf.value
            puts "Updating UCF: #{row['user_id']} Name: #{name}, Found #{ucf.value}}"
            ucf.update(value: val)
          end
        else
          if val
            puts "Creating UCF: #{row['user_id']} Name: #{name}, value: #{val}"
            UserCustomField.create(user_id: user_id, name: name, value: val)
          end
        end
      end
    end
  end
end

```

After modifying it, you’d put it in ` /var/www/discourse/lib/tasks` inside the container and `rake user_fields:import_csv["YOUR-CSV.csv"]`

If you need help modifying it for your needs, email me your CSV (or at least the headers and first few rows) and I’ll get you an estimate.

---

_[View the full topic](https://meta.discourse.org/t/update-user-information-in-bulk/220271)._
