Giter Club home page Giter Club logo

Comments (10)

Fivell avatar Fivell commented on July 30, 2024

please, add your database schema and csv file sample

from active_admin_import.

ericcumbee avatar ericcumbee commented on July 30, 2024

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.

Fivell avatar Fivell commented on July 30, 2024

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.

Fivell avatar Fivell commented on July 30, 2024

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.

ericcumbee avatar ericcumbee commented on July 30, 2024

I was already on 2.0.0 headers_rewrite doesnt appear to be working either

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

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.

ericcumbee avatar ericcumbee commented on July 30, 2024

https://github.com/ericcumbee/pbapp

from active_admin_import.

ericcumbee avatar ericcumbee commented on July 30, 2024

No errors everything appears to execute but I never see any insert queries run.

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

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.

ericcumbee avatar ericcumbee commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.