-
-
Save ArtOfCode-/85a917242040e4cd5f02863dec9a8331 to your computer and use it in GitHub Desktop.
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 '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