Skip to content

Instantly share code, notes, and snippets.

@henrypoydar
Created March 28, 2009 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrypoydar/87216 to your computer and use it in GitHub Desktop.
Save henrypoydar/87216 to your computer and use it in GitHub Desktop.
# get the user record for which you'd like to import
tom = User.first
everyone_view = [{'user_group_id' => tom.account.user_groups.everyone.id}].map {|group| [group['user_group_id'], 'default']}
# create the import, pointing to the csv
UserActionLogger.log_actions_with(tom) { $i = Import.create(:views => everyone_view, :user => tom, :source => File.open("/Users/danferranti/Desktop/Tuckerbrook-test.csv"), :state => 'preparing') }
# check that the headers map properly
$i.map_header
# set any global tag names if you'd like for the import
# $i.tag_names = []
# run the import (3-4 contacts per second on local machine fwiw)
Import.import_execute($i)
# check the failed row numbers of CSV
$i.failed_row_identifiers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment