Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: #help in reading from csv file
Learnatwoa learn@woa.hu
12/7/2006 10:36:00 AM
Here how you can access correctly a csv file. This works and is more in
the ruby style.
require 'csv'
CSV::Reader.parse(File.open('my.csv', 'rb')) do |row|
next if row.first.nil? #skip blank lines
create_product(row)
end
But you can be more restrictive by changing the condition on the next
by:
next unless row.size == 5 #skip all lines without the exact number of
columns (5 here)
I hope this will help you,
++
jerome () {
c = Woa! Kft
w =
http://...
}
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: #help in reading from csv file
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password