import users into redmine from comma delinted text file
Looked around the forum and wiki but could not find anything that would help. I basically have a comma delimited text file with user ids, names and email addresses. Its a big file many entries. How would I import this to redmine as registered users?
Can i just put them in the mysql database? Thanks
There are 2 ways to do this. One is using an import script and another is using mysql. In my case I didn't need to import users but I did need to import our projects from an excel spreadsheet. I've included the code I have
require 'csv' # csv issues import for redmine # Will convert a csv into a issues bulkloader into redmine # Column names # row=Nb Number,row=Product,row=Element,row=Type,row=Queue, # row=KeyWord,row=Responsible,row=Case Descriptions,row=Days, # row=Planned Delivery,row=Version # desc <<-END_DESC Bulk loading of issues from a CSV file. Available options: * filepath => path to the text file. * project => id or identifier of project Example: rake redmine:csv_import filepath="~/import.csv" project="test" END_DESC namespace :redmine do task :csv_import => :environment do @firstrow = true @count = 1 CSV.Open(ENV['filepath'],'r') do |row| if not firstrow @i = Issue.new @i.project => Project.find_by_name(ENV['project']) # If not a feature it's a bug if row.contains("SUG") @i.tracker => Tracker.find_by_id(2) else @i.tracker => Tracker.find_by_id(1) end if row.contains("TOP PRIORITY) @i.priority => Enumeration.find_by_id(7) elseif row.contains("HIGH PRIORITY") @i.priority => Enumeration.find_by_id(5) elseif row.contains("MEDIUM PRIORITY") @i.priority => Enumeration.find_by_id(4) else @i.priority => Enumeration.find_by_id(3) end @i.author => Users.find(5) @i.subject => truncate(row, 50) @i.description => row @i.status => IssuesStatus.find_by_id(1) @i.save count += 1 end firstrow = nil end end
For the users table I did a mysql import (matching column names, matching enumerators, etc) and that also seemed to work. You'll need to find the properties for the user class and modify my script to match.
Great! That is just what I needed. Thank you
I am looking for an csv importer like this. thank you very much.
Could you please post a sample CSV file?
When I ran the rake: (Windows XP)
C:\Program Files\redmine\current\script>rake redmine:csv_import filepath="C:\issues.csv" project="test01" --trace
(in C:/Program Files/redmine/current) rake aborted! Don't know how to build task 'redmine:csv_import' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1728:in `' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2050:in `invoke_task' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 C:/Program Files/Ruby/bin/rake:19:in `load' C:/Program Files/Ruby/bin/rake:19 C:\Program Files\redmine\current\script>
Hi Joe Chin,
Could you help to guide me for detailed steps ? I dont know how to run the script you gave.