Skip to content

Instantly share code, notes, and snippets.

@ecleel
Forked from anonymous/appstore.rb
Created December 11, 2012 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecleel/4262588 to your computer and use it in GitHub Desktop.
Save ecleel/4262588 to your computer and use it in GitHub Desktop.
# 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