Prev | Current Page 193 | Next

David Berube

"Practical Reporting with Ruby and Rails"

If you tried that, FasterCSV
would treat your entire array as one long row of data.
You can use techniques like those described here to create files people can easily
import into programs like Microsoft Excel, Microsoft Access, OpenOffice.org, and File-
Maker Pro.
Converting PayPal CSV Data
Listing 7-1 shows the script that uses FasterCSV to read data from the CSV file and then
uses Active Record to load it into your MySQL database.
Listing 7-1. Using ActiveRecord to Load PayPal Data from CSV (paypal_load_data.rb)
require 'active_record'
require 'fastercsv'
(puts "usage: #{$0} csv_filename";
exit) unless ARGV.length==1
CHAPTER 7 n TRACKING EXPENDITURES WITH PAYPAL 138
paypal_source_file = ARGV.shift
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:host => 'insert_your_mysql_hostname_here',
:username => 'insert_your_mysql_username_here',
:password => 'insert_your_mysql_password_here',
:database => 'paypal')
class PaypalTransaction < ActiveRecord::Base
end
class String
def columnize
self.


Pages:
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
kamerzysta chelm profesjonalne wizualizacje 3d Restauracje Warszawa torpado opony przemysłowe