Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #C:\Documents and Settings\Michael\Desktop>ruby test.rb
  2. #test.rb:5: undefined method `+' for nil:NilClass (NoMethodError)
  3. # from test.rb:3:in `foreach'
  4. # from test.rb:3
  5.  
  6. array = Array.new
  7.  
  8. File.foreach("All_fips55_delim.txt") do |line|
  9. newline = line.sub(/[0-9]*\t[0-9]*\t[0-9]*\t[a-zA-Z0-9 ]*\t[A-Z0-9]{2}\t([a-zA-Z ]*)\t\t\t([A-Z]{2})/, '')
  10. row = $1 + '|' + $2
  11. array << row
  12. end
  13.  
  14. puts array.count
  15.  
  16. #line = "1000759 37 39540 Populated Place U6 Lowgap NC 01 171 Surry 36.5256863 -80.8672961 2744"
  17. #line2 = "648686 27 47221 Populated Place C5 North Saint Paul MN 01 123 Ramsey 45.0124657 -92.9918828 5320"
  18. #newline = line2.sub(/[0-9]*\t[0-9]*\t[0-9]*\t[a-zA-Z0-9 ]*\t[A-Z0-9]{2}\t([a-zA-Z ]*)\t\t\t([A-Z]{2})/, '')
  19. #puts "\n\n\n"
  20. #puts "New line: " + newline + "\n\n\n"
  21. #puts "$1: " + $1 + "\n\n\n"
  22. #puts "$2: " + $2 + "\n\n\n"
  23. #puts $1 + "|" + $2
Add Comment
Please, Sign In to add comment