Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
Created January 18, 2010 17:25

Revisions

  1. rgreenjr revised this gist Jan 19, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion goodreads_csv_filter.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/env ruby -w
    #
    # Trims Goodreads CSV files so they import into Delicious Library the essential data only.
    # Trims Goodreads CSV files so they import into Delicious Library essential data only.
    #

    require 'rubygems'
  2. rgreenjr revised this gist Jan 18, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion goodreads_csv_filter.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/usr/bin/ruby -w
    #!/usr/bin/env ruby -w
    #
    # Trims Goodreads CSV files so they import into Delicious Library the essential data only.
    #
  3. rgreenjr revised this gist Jan 18, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion goodreads_csv_filter.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/usr/bin/ruby -w
    #
    # Trims Goodreads CSV files so they import into Delicious Library only essential data
    # Trims Goodreads CSV files so they import into Delicious Library the essential data only.
    #

    require 'rubygems'
  4. rgreenjr created this gist Jan 18, 2010.
    19 changes: 19 additions & 0 deletions goodreads_csv_filter.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/usr/bin/ruby -w
    #
    # Trims Goodreads CSV files so they import into Delicious Library only essential data
    #

    require 'rubygems'
    require 'faster_csv'

    path = ARGV.empty? ? "/Users/rgreen/Downloads/goodreads_export.csv" : ARGV[0]

    puts "Title,Author,ASIN,ISBN"

    text = ""
    File.open(path) { |file| text = file.read }
    text.gsub!(/",="/, "\",\"")

    FasterCSV.parse(text, :headers => true) do |row|
    puts "\"#{row[0]}\",\"#{row[1]}\",\"#{row[4]}\",\"#{row[4]}\""
    end