desc "Generate the Neo4j database of counties"
task :generate_adjacent_counties_database do
file = File.open('db/adjacent_counties.txt')
data = file.read.force_encoding("iso-8859-1").split("\n\n\n")
data.each do |string|
parent_node = nil
string.each_line do |line|
county = line.scan(/\[\[(.*), (.*)\]\]/)
parent_node = Neography::Node.find("counties", "name", county[0][0])
if parent_node.nil?
parent_node = Neography::Node.create("name" => county[0][0], "state" => county[0][1])
end
end
end
end
I'm trying to create a rake task to generate a database based on a text file, here's the error I'm getting:
Chintan at mbp in ~/Documents/Work/Aidin on feature/49442033_generate_database_of_adjacent_counties!
± rake generate_adjacent_counties_database
rake aborted!
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/connection.rb:140:in `handle_4xx_500_response'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/connection.rb:112:in `evaluate_response'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/connection.rb:37:in `get'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/rest/indexes.rb:65:in `find_by_key_value'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/rest/indexes.rb:56:in `find'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/rest.rb:209:in `find_node_index'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/gems/neography-1.0.9/lib/neography/index.rb:30:in `find'
/Users/Chintan/Documents/Work/Aidin/lib/tasks/generate_adjacent_counties_database.rake:18:in `block (3 levels) in <top (required)>'
/Users/Chintan/Documents/Work/Aidin/lib/tasks/generate_adjacent_counties_database.rake:16:in `each_line'
/Users/Chintan/Documents/Work/Aidin/lib/tasks/generate_adjacent_counties_database.rake:16:in `block (2 levels) in <top (required)>'
/Users/Chintan/Documents/Work/Aidin/lib/tasks/generate_adjacent_counties_database.rake:14:in `each'
/Users/Chintan/Documents/Work/Aidin/lib/tasks/generate_adjacent_counties_database.rake:14:in `block in <top (required)>'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Chintan/.rvm/gems/ruby-1.9.3-p327@aidin/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => generate_adjacent_counties_database
(See full trace by running task with --trace)
Code:
I'm trying to create a rake task to generate a database based on a text file, here's the error I'm getting:
Any ideas?