class DataController < ApplicationController
	def addmore
		allRows = Array.new

		# CSV Arrangement
		# Name Dept Year Hall

		counter = 0

		CSV.foreach("public/list-assets/list-66.csv") do |row|
			row[2] = row[2].delete(' ') # remove space from year
			allRows.push(row)

			a = Alumni.new
			a.name = row[0]
			a.year = row[2]
			if row[3]
				a.hall = row[3]
			end

			a.department = row[1]

			a.save!
			allRows.push(row)

			counter += 1
		end

		puts counter

		render plain: allRows.inspect()

	end
end

class DataController < ApplicationController
	def addmore
		allRows = Array.new

		# CSV Arrangement
		# Name Dept Year Hall

		counter = 0

		require('open-uri')

		open('file.csv', 'wb') do |file|
			file << open(ENV['GIST_DATA_URL']).read
		end

		CSV.foreach('file.csv') do |row|
			
			row[2] = row[2].delete(' ') # remove space from year

			a = Alumni.new
			a.name = row[0]
			a.year = row[2]
			if row[3]
				a.hall = row[3]
			end

			a.department = row[1]


			counter	+= 1

			if counter < 20
				next
			end

			if not a.save!
				allRows.push(row)
			end

			if counter > 03
				break
			end
		end

		puts counter

		allRows.push(counter)

		File.delete('file.csv')

		render plain: allRows.inspect()

	end
end

Store file in gists, rather than on disk
Store file in gists, rather than on disk

- Avoid the file URL becoming public by putting it in an environment
  variable.

Signed-off-by: Siddharth Kannan <805f056820c7a1cecc4ab591b8a0a604b501a0b7@gmail.com>
