Created
December 11, 2012 21:51
-
-
Save anonymous/4262552 to your computer and use it in GitHub Desktop.
I used this code for listing and clearing list of itunes json entires
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'csv' | |
require 'json' | |
columns = %w(trackName trackViewUrl artistName version price releaseDate formattedPrice fileSizeBytes description) | |
exclude = [] # Here you can execlude list of urls you want | |
data = JSON.load(DATA.read) | |
puts data.count | |
CSV.open("export.csv", "w") do |csv| | |
csv << data.first.keep_if {|key, value| columns.include?(key) }.keys | |
data.each do |hash| | |
appurl = hash['trackViewUrl'] | |
# unless appurl.nil? | |
# appurl = appurl.split('?')[0] | |
# end | |
if !exclude.include?(appurl) | |
csv << hash.keep_if {|key, value| columns.include?(key) }.values | |
end | |
end | |
end | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment