# Importing data for excel file or csv file

**URL:** <https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666>\
**Category:** Rails\
**Created:** [December 7, 2005, 11:03am UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666 "2005-12-07T11:03:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 7, 2005, 11:03am UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666/1 "2005-12-07T11:03:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 7, 2005, 1:38pm UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666/2 "2005-12-07T13:38:52Z")

</div>

Brutyn N. wrote:

> [http://lists.rubyonrails.org/mailman/listinfo/rails](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

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 7, 2005, 2:23pm UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666/3 "2005-12-07T14:23:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 7, 2005, 5:43pm UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666/4 "2005-12-07T17:43:53Z")

</div>

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](http://article.gmane.org/gmane.comp.lang.ruby.rails/33460)

Thanks in advance  
Nick

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 8, 2005, 4:33am UTC](https://www.ruby-forum.com/t/importing-data-for-excel-file-or-csv-file/49666/5 "2005-12-08T04:33:44Z")

</div>

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
