Created
March 28, 2017 09:55
-
-
Save a13e/d84cc47d1b998ca59943d0c019abdb48 to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
| 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