Skip to content

Instantly share code, notes, and snippets.

@Largo
Created December 2, 2016 07:23
Show Gist options
  • Save Largo/af6d3065cf4eae01e1b0f5750ea2aa63 to your computer and use it in GitHub Desktop.
Save Largo/af6d3065cf4eae01e1b0f5750ea2aa63 to your computer and use it in GitHub Desktop.
require 'csv'
require 'open-uri'
zeilen = CSV.read('images.csv', { :col_sep => ';' })
listeMitBilderProSku = zeilen.group_by{|x| x[0] }
#p listeMitBilderProSku
listeMitBilderProSku.each do |bilderProSku|
sku = bilderProSku[0]
bildNr = 0
bilderProSku[1].each do |bildProSku|
url = bildProSku[1]
if url == 'value'
next
end
p url
download = open(url)
extension = File.extname(url)
filename = 'B_' + sku + '_' + bildNr.to_s + extension
IO.copy_stream(download, 'downloads/' + filename)
bildNr += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment