Created
November 25, 2015 11:48
-
-
Save bkenny/45813bc5c7d68dd49275 to your computer and use it in GitHub Desktop.
Generate unique codes in a CSV
This file contains 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
require 'bazaar' | |
require 'rails' | |
require "csv" | |
tokens_array = [] | |
array_complete = false | |
while array_complete == false do | |
token = Bazaar.object | |
tokens_array << token unless tokens_array.include?(token) | |
puts "Added token: #{token}, number: #{tokens_array.count}" | |
array_complete = true if tokens_array.count == 5000 | |
end | |
CSV.open("codes.csv", "wb") do |csv| | |
puts "Creating CSV" | |
tokens_array.each do |token| | |
csv << [token] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment