Comments (10)
please, add your database schema and csv file sample
from active_admin_import.
create_table "voters", :force => true do |t|
t.string "LastName"
t.string "FirstName"
t.string "MiddleName"
t.string "SuffixName"
t.string "PrimaryAddress"
t.string "PrimaryCity"
t.string "PrimaryState"
t.string "PrimaryZip"
t.string "PrimaryZip4"
t.string "PrimaryOddEvenCode"
t.string "PrimaryPhone"
t.string "Gender"
t.string "PartyCode"
t.string "VoterScore"
t.string "CDName"
t.string "LDName"
t.string "PrecinctNumber"
t.string "PrecinctName"
t.string "VoterKey"
t.string "HHRecId"
t.string "StateVoterId"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
LastName,FirstName,MiddleName,SuffixName,PrimaryAddress,PrimaryCity,PrimaryState,PrimaryZip,PrimaryZip4,PrimaryOddEvenCode,PrimaryPhone,Gender,PartyCode,VoterScore,CDName,LDName,PrecinctNumber,PrecinctName,VoterKey,HHRecId,StateVoterId
ADKINSON,AMANDA,L,,145 Clover Rd,Rochelle,GA,31079,3102,O,,F,3,0,8,155,3,WILLIAMSON MILL,3114129,26820,5436023
ADKINSON,WAYNE,T,,113 Clover Rd,Rochelle,GA,31079,3102,O,,M,2,2,8,155,3,WILLIAMSON MILL,614841,26819,1044088
ADKINSON,RONNIE,LEWIS,,165 Clover Rd,Rochelle,GA,31079,3102,O,,M,5,1,8,155,3,WILLIAMSON MILL,3326920,26821,5765258
ADKISON,MARGRET,MORRIS,,165 Clover Rd,Rochelle,GA,31079,3102,O,,F,5,3,8,155,3,WILLIAMSON MILL,366631,26933,614706
from active_admin_import.
I just tried it and have exception while uploading, what version are you using?
PS
v 2.0.0 doesn't support camelcase property names (LastName -> last_name ...) but it has option to pass hash named "headers_rewrites"
I will update this issue as soon as I get my notebook.
from active_admin_import.
update to v 2.0.0 and try
ActiveAdmin.register Voter do
active_admin_import :validate => true,
:col_sep => ',',
:before_import => proc{|importer| Voter.delete_all},
:back => :index,
:batch_size => 1000,
:timestamps =>true,
:headers_rewrites => {"LastName"=>"LastName", "FirstName"=>"FirstName", "MiddleName"=>"MiddleName", "SuffixName"=>"SuffixName", "PrimaryAddress"=>"PrimaryAddress", "PrimaryCity"=>"PrimaryCity", "PrimaryState"=>"PrimaryState", "PrimaryZip"=>"PrimaryZip", "PrimaryZip4"=>"PrimaryZip4", "PrimaryOddEvenCode"=>"PrimaryOddEvenCode", "PrimaryPhone"=>"PrimaryPhone", "Gender"=>"Gender", "PartyCode"=>"PartyCode", "VoterScore"=>"VoterScore", "CDName"=>"CDName", "LDName"=>"LDName", "PrecinctNumber"=>"PrecinctNumber", "PrecinctName"=>"PrecinctName", "VoterKey"=>"VoterKey", "HHRecId"=>"HHRecId", "StateVoterId"=>"StateVoterId"}
end
timestamps option will generate missed data for updated_at and created_at
headers_rewrites will help to create mappers from csv columns to database columns , it needed because you don't use default naming convension
from active_admin_import.
I was already on 2.0.0 headers_rewrite doesnt appear to be working either
from active_admin_import.
Do you have any error ? I tried it and it is ok for me, your csv file was processed successfully. Can you upload project sample to github to let me understand what is going on.
from active_admin_import.
https://github.com/ericcumbee/pbapp
from active_admin_import.
No errors everything appears to execute but I never see any insert queries run.
from active_admin_import.
I just cloned your application and made import
Here what I've got http://gyazo.com/1a913f5440b504f308c5cd04b6564b9a
My output is
SQL (3.1ms) DELETE FROM "voters"
(0.1ms) begin transaction
(0.5ms) INSERT INTO "voters" ("LastName","FirstName","MiddleName","SuffixName","PrimaryAddress","PrimaryCity","PrimaryState","PrimaryZip","PrimaryZip4","PrimaryOddEvenCode","PrimaryPhone","Gender","PartyCode","VoterScore","CDName","LDName","PrecinctNumber","PrecinctName","VoterKey","HHRecId","StateVoterId","created_at","updated_at") VALUES ('ADKINSON','AMANDA','L',NULL,'145 Clover Rd','Rochelle','GA','31079','3102','O',NULL,'F','3','0','8','155','3','WILLIAMSON MILL','3114129','26820','5436023','2013-05-26 20:53:28.295464','2013-05-26 20:53:28.295505')
(0.1ms) INSERT INTO "voters" ("LastName","FirstName","MiddleName","SuffixName","PrimaryAddress","PrimaryCity","PrimaryState","PrimaryZip","PrimaryZip4","PrimaryOddEvenCode","PrimaryPhone","Gender","PartyCode","VoterScore","CDName","LDName","PrecinctNumber","PrecinctName","VoterKey","HHRecId","StateVoterId","created_at","updated_at") VALUES ('ADKINSON','WAYNE','T',NULL,'113 Clover Rd','Rochelle','GA','31079','3102','O',NULL,'M','2','2','8','155','3','WILLIAMSON MILL','614841','26819','1044088','2013-05-26 20:53:28.295464','2013-05-26 20:53:28.295505')
(0.1ms) INSERT INTO "voters" ("LastName","FirstName","MiddleName","SuffixName","PrimaryAddress","PrimaryCity","PrimaryState","PrimaryZip","PrimaryZip4","PrimaryOddEvenCode","PrimaryPhone","Gender","PartyCode","VoterScore","CDName","LDName","PrecinctNumber","PrecinctName","VoterKey","HHRecId","StateVoterId","created_at","updated_at") VALUES ('ADKINSON','RONNIE','LEWIS',NULL,'165 Clover Rd','Rochelle','GA','31079','3102','O',NULL,'M','5','1','8','155','3','WILLIAMSON MILL','3326920','26821','5765258','2013-05-26 20:53:28.295464','2013-05-26 20:53:28.295505')
(0.1ms) INSERT INTO "voters" ("LastName","FirstName","MiddleName","SuffixName","PrimaryAddress","PrimaryCity","PrimaryState","PrimaryZip","PrimaryZip4","PrimaryOddEvenCode","PrimaryPhone","Gender","PartyCode","VoterScore","CDName","LDName","PrecinctNumber","PrecinctName","VoterKey","HHRecId","StateVoterId","created_at","updated_at") VALUES ('ADKISON','MARGRET','MORRIS',NULL,'165 Clover Rd','Rochelle','GA','31079','3102','O',NULL,'F','5','3','8','155','3','WILLIAMSON MILL','366631','26933','614706','2013-05-26 20:53:28.295464','2013-05-26 20:53:28.295505')
(1.3ms) commit transaction
Only reason I have in my mind now that it is broken csv file...
from active_admin_import.
odd something must be off with that file. copied and pasted the entire contents into another file and it imported fine.
from active_admin_import.
Related Issues (20)
- Why version lock? HOT 3
- Getting SQL syntax error, as the values in the insert statement is having extra comma at the end. Also 'created_at' value is coming as null. HOT 3
- Add roles after importing users HOT 4
- Errors on the base of an object break active_admin_import HOT 1
- Wrong count in notification after successful import HOT 2
- on the fly by association - not working for a particular column
- need possibility to wrap whole process inside transaction HOT 1
- Proposal: live processing feedback using rails 5 action cables. HOT 1
- Handle a specific error on import HOT 3
- Creating associations without foreign keys
- Deprecation warnings in log
- Send to importer form additional params
- Calling batch_slice_columns multiple times results in unexpected behavior
- Ability to update or create based on id column being present
- Ability to import serialized hash HOT 1
- Ruby 3.0 Support
- ActiveModel::Errors#keys is deprecated and will be removed in Rails 6.2. HOT 2
- Proposal: Array conversion
- Release version 5? HOT 1
- Error if csv file consists empty columns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_admin_import.