Forum: Ruby on Rails Importing data for excel file or csv file

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
brutyn_nick (Guest)
on 2005-12-07 12:03
(Received via mailing list)
hey,

i have this website (with ajax also) with lot of records of employee,
and as an
extra feature i want that the customer can import his employeelist
(perhaps 100+
records), lot of work to do this manually.

i would create a template like this
Firstname    Lastname    Phone
xxxx         xxxxx       xxxxx
yyyy         yyyyy       yyyyy

then they upload the excel file or save it as csv file (with spacing
characters), i read the file and loop through it, and save the records
in the
database.

does anyone has any experience with this???
thanks in advance.
kevin.jackson (Guest)
on 2005-12-07 14:38
(Received via mailing list)
Brutyn N. wrote:

>
>http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
My advice is to look at FasterCSV - I've just done/am refactoring
something very similar right now - it's very few lines of code (and
sorry I cannot provide them)

Kev
brutyn_nick (Guest)
on 2005-12-07 15:23
(Received via mailing list)
hey,

thanks for that,
is there any doc for FasterCSV , cuz i download the zip and no docs in
there :s

i just need to read csv file, ead lines, and insert into database, thats
all


thx
brutyn_nick (Guest)
on 2005-12-07 18:43
(Received via mailing list)
Hey,

I am still working on this importing stuff. This all works till now.
I have clients, here i keep for each client the country info.
Like this:

<select name="client[country]">
<%= country_options_for_select(selected = @client.country,
   priority_countries = ['Belgium', 'Netherlands'] ) %>
</select>

But now also for the importing with csv, how must i slove this problem?
In the database is save the id of the countries, but the use will
probably fill
in the excel/csv file the name (what is normal).

Any ideas??

Also check for other problem (parsing validation to strings)
http://article.gmane.org/gmane.comp.lang.ruby.rails/33460

Thanks in advance
Nick
justin (Guest)
on 2005-12-08 05:33
(Received via mailing list)
Brutyn N. wrote:
> hey,
>
> thanks for that,
> is there any doc for FasterCSV , cuz i download the zip and no docs in there :s

There's a Readme, which tells you "See FasterCSV for documentation."

In other words, the documentation is RDoc documentation for the
FasterCSV class, which you will find in the file faster_csv.rb

And there are the tests...

regards

   Justin
This topic is locked and can not be replied to.