Skip to content

Instantly share code, notes, and snippets.

@pahnin
Last active December 22, 2015 17:19
Show Gist options
  • Save pahnin/6505762 to your computer and use it in GitHub Desktop.
Save pahnin/6505762 to your computer and use it in GitHub Desktop.
converts txt file to csv with names and phone numbers
#!/usr/bin/env ruby
lines = IO.readlines("phonebook.txt").map do |line|
lm = line.gsub(/-|\s/,'').match(/([a-zA-Z]+)(\d+)/)
"#{lm[1]},#{lm[2]}" unless lm.nil?
end
File.open("Gulties.csv","w") do |file|
file.puts lines
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment