Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement