Skip to content

Instantly share code, notes, and snippets.

@ArtOfCode-
Created October 21, 2018 23:55
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 ArtOfCode-/85a917242040e4cd5f02863dec9a8331 to your computer and use it in GitHub Desktop.
Save ArtOfCode-/85a917242040e4cd5f02863dec9a8331 to your computer and use it in GitHub Desktop.
require 'open-uri'
# SSL_VERIFY_NONE because my system has forgotten how to SSL. You probably want to remove this.
file = open('https://data.stackexchange.com/interpersonal/csv/1136923', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
data = file.read
titles = data.split("\n")[1...-1].map { |l| l.gsub('"', '').strip }
titles.in_groups_of(5).map(&:compact).each_with_index do |g, i|
post = Post.create title: "HNQ group #{i + 1}"
g.each do |t|
post.comments.create(body: t)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment