Importing data for excel file or csv file


#1

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.


#2

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


#3

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


#4

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:

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

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


#5

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