Skip to content

Instantly share code, notes, and snippets.

@a13e
Created March 28, 2017 09:55
Show Gist options
  • Select an option

  • Save a13e/d84cc47d1b998ca59943d0c019abdb48 to your computer and use it in GitHub Desktop.

Select an option

Save a13e/d84cc47d1b998ca59943d0c019abdb48 to your computer and use it in GitHub Desktop.
require 'csv'
lines_for_output = []
CSV.foreach("momoda.csv") do |row|
row_text = row[0] + row[1]
line = {}
line[:rank] = row_text.scan(/.*位/).first
line[:bank_name] = row_text.split(/.*位/, 2)[1].gsub(/[\d]/, "")
line[:amount] = row_text.split(/.*位/, 2)[1].gsub(/[^\d]/, "")
lines_for_output << line
end
CSV.open('momoda_new_list.csv','w') do |csv|
lines_for_output.each do |line|
csv << [
line[:rank],line[:bank_name],line[:amount]
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment