Created
July 5, 2018 05:18
-
-
Save deepakmahakale/9ba7a2e989779d7b767b78a0d5f84ac9 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 'csv' | |
input_file = "#{Rails.root}/High School Database CSV.csv" | |
file_1 = CSV.open("#{Rails.root}/High_School_Database_#{1}.csv", 'w') | |
file_2 = CSV.open("#{Rails.root}/High_School_Database_#{2}.csv", 'w') | |
file_3 = CSV.open("#{Rails.root}/High_School_Database_#{3}.csv", 'w') | |
count = 0 | |
CSV.foreach(input_file) do |row| | |
if count < 400000 | |
file_1 << row | |
elsif count < 800000 | |
file_2 << row | |
else | |
file_3 << row | |
end | |
count +=1 | |
end | |
file_1.close | |
file_2.close | |
file_3.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment