Permalink
Browse files

switched to the basic CSV writer to generate the csv file

  • Loading branch information...
jonathanb
jonathanb committed Mar 19, 2011
1 parent e70142d commit a0ea463a359422a3d03ab34bb343e200ae6769b9
Showing with 9 additions and 2 deletions.
  1. +9 −2 scrape.rb
View
@@ -1,6 +1,7 @@
require "rubygems"
require "bundler/setup"
Bundler.require(:default)
+require 'csv'
class Scraper
# form field names
@@ -62,8 +63,14 @@ def self.scrape_page
# output to CSV file
File.open(OUTPUT_FILENAME, 'w') do |f|
- f.puts CLASS_NAMES.join(',')
- entries.each {|e| f.puts e.values.join(',')}
+
+ end
+
+ CSV.open(OUTPUT_FILENAME, "wb") do |csv|
+ csv << CLASS_NAMES
+ entries.each do |e|
+ csv << CLASS_NAMES.map {|c| e[c]}
+ end
end
end

0 comments on commit a0ea463

Please sign in to comment.