Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #5086
| From | Bala TS <bdeveloper01@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: how to mark color on csv file |
| Date | 2011-05-26 07:23 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <4c86c0daa4e6b88041e63122c4348a06@ruby-forum.com> (permalink) |
| References | <6ae67f143353b6bb579035ae562a007f@ruby-forum.com> |
require 'fastercsv'
FasterCSV.parse(my_string, :headers => true) do |row|
Fruit.create!(
:name => row['name'],
:color => row['color'],
:tasty => row['tasty'] == 'true',
:qty => row['qty].to_i
)
end
For Ruby 1.9, just rename FasterCSV to CSV and fastercsv to csv:
require 'csv'
CSV.parse(my_string, :headers => true) do |row|
# same as ruby-1.8
end
so you must need fastercsv gem if you install then it is possible
bye
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar | Unroll thread
how to mark color on csv file Gavin Chen <dickyhide@gmail.com> - 2011-05-26 00:57 -0500
Re: how to mark color on csv file Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-26 01:23 -0500
Re: how to mark color on csv file Gavin Chen <dickyhide@gmail.com> - 2011-05-26 02:07 -0500
Re: how to mark color on csv file Phillip Gawlowski <cmdjackryan@googlemail.com> - 2011-05-26 02:26 -0500
Re: how to mark color on csv file Bala TS <bdeveloper01@yahoo.com> - 2011-05-26 07:23 -0500
csiph-web