Hey, What way is the best to do imports of CSV files?
If you mean CSV to DB records, you should use fixtures. On terminal window. rake db:fixtures:load FIXTURES=table_name RAILS_ENV=development Change ''table_name'' and RAILS_ENV=~ as you like. This will import CSV as DB records.
Thank''s Masuda, but what im looking for is a solution where the user can upload a CSV file an update the DB records that way. On 22 Sep., 08:59, Masuda <msd....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you mean CSV to DB records, you should use fixtures. > > On terminal window. > rake db:fixtures:load FIXTURES=table_name RAILS_ENV=development > > Change ''table_name'' and RAILS_ENV=~ as you like. > This will import CSV as DB records.
Goro Kuroita wrote:> If you mean CSV to DB records, you should use fixtures. > > On terminal window. > rake db:fixtures:load FIXTURES=table_name RAILS_ENV=development > > Change ''table_name'' and RAILS_ENV=~ as you like. > This will import CSV as DB records.Can you exapnd on this idea, I needed to bring in a whole load of records to my app from a CSV and wrote a custom method (with fasterCSV) to read them in. Am now wondering if fixtures would have been a better way to go and maybe I should be using them in future as I import more data to my app? -- Posted via http://www.ruby-forum.com/.
Goro Kuroita wrote:> If you mean CSV to DB records, you should use fixtures. > > On terminal window. > rake db:fixtures:load FIXTURES=table_name RAILS_ENV=development > > Change ''table_name'' and RAILS_ENV=~ as you like. > This will import CSV as DB records.Poppycock. Fixtures are so broken that they''re worth avoiding completely (I wish they''d be removed from Rails). For prepopulating the DB, use the DB''s native CSV import or something like seed_fu. For dynamic CSV import in the application, fastercsv might be useful. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Why do you say that fixtures are broken? On Sep 22, 4:22 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote:> Goro Kuroita wrote: > > If you mean CSV to DB records, you should use fixtures. > > > On terminal window. > > rake db:fixtures:load FIXTURES=table_name RAILS_ENV=development > > > Change ''table_name'' and RAILS_ENV=~ as you like. > > This will import CSV as DB records. > > Poppycock. Fixtures are so broken that they''re worth avoiding > completely (I wish they''d be removed from Rails). For prepopulating the > DB, use the DB''s native CSV import or something like seed_fu. For > dynamic CSV import in the application, fastercsv might be useful. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.
Milan Dobrota wrote:> Why do you say that fixtures are broken? >The short answer is that they''re unsuited to their intended purpose (populating the test DB). They''re better than nothing, but are an inferior alternative to other solutions now available. I''ll get into the long answer if you really want, or just search the list archives. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.