Prev | Current Page 191 | Next

David Berube

"Practical Reporting with Ruby and Rails"

See the Ruby documentation at http://www.ruby-doc.org/stdlib/
libdoc/csv/rdoc/index.html for details.
Also, you need to create a MySQL database to store the data. You can do so by using
the following command:
mysqladmin -u mysql_username -p paypal
Using FasterCSV
To give you an idea of how FasterCSV works, let??™s look at the simplest use of FasterCSV:
when you have a string consisting of CSV and you would like to parse it one row at a time.
Here??™s an example:
require "fastercsv"
csvdata = "moonrock,10000,safe\n"
csvdata << "collectible spoon,10,cupboard\n"
csvdata << "scratched Billy Joel CD,1,desk\n"
FasterCSV.parse(csvdata) do |row|
item, value, location = *row
puts "I own a #{item}, it's worth $#{value}, and I keep it in my #{location}."
end
The result is as follows:
I own a moonrock, it's worth $10000, and I keep it in my safe.
I own a collectible spoon, it's worth $10, and I keep it in my cupboard.
I own a scratched Billy Joel CD, it's worth $1, and I keep it in my desk.
This example uses the parse method of FasterCSV to loop through each row.


Pages:
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
Wczasy nad morzem oferty spa Spa Ciechocinek kolokacja rack zamykanie naczynek bielsko