-
-
Save octosteve/2d9055e0cb9487091479 to your computer and use it in GitHub Desktop.
This file contains 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
1-28-2015 NYC LPEP $20.16 | |
1-29-2015 DEN $17.06 | |
1-30-2015 Aden Food Market $11.89 | |
1-30-2015 ZIZI LIMONA $96.65 | |
1-31-2015 FOODTOWN $67.49 | |
2-4-2015 NYC-TAXI $15.96 | |
2-4-2015 DRAM $21.00 | |
2-4-2015 BALTHAZAR $42.40 | |
2-5-2015 DINER $31.13 | |
2-7-2015 DOTORY $23.60 | |
2-7-2015 ZABLOZKIS BAR $13.00 | |
2-8-2015 CENTER WORLD CAR SVCE $7.56 | |
2-8-2015 ADEN FOOD MARKET $26.50 | |
2-8-2015 NYC-TAXI $14.00 | |
2-8-2015 MARLOW AND SONS WINE $18.24 | |
2-8-2015 PEGU $54.73 | |
2-9-2015 SQ SUMMERS JUICE & CO $6.00 | |
2-9-2015 DUANE READE #14426 $10.49 | |
2-9-2015 SQ SUMMERS JUICE & CO $18.00 | |
2-9-2015 LE PAIN QUOTIDIEN $19.93 | |
2-9-2015 ID COED, INC. $69.00 | |
2-10-2015 SQ SUMMERS JUICE & CO $11.50 | |
2-10-2015 DUANE READE #14426 $766.53 | |
2-10-2015 DINER $31.13 |
This file contains 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 'date' | |
Charge = Struct.new(:date, :location, :price) do | |
def date | |
@parsed_date ||= Date.strptime(self[:date], '%m-%d-%Y') | |
end | |
end | |
raw_charges = File.read('charges') | |
parsed_charges = raw_charges.scan(/(\d+\-\d+\-\d+) (.*?) (\$.*)$/) | |
charge_list = parsed_charges.map {|charge| Charge.new(*charge)} | |
charge_list.each do |charge| | |
puts "Spent #{charge.price} at #{charge.location} on #{charge.date.strftime('%A %B %d %Y')}" | |
end | |
This file contains 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 'pry' | |
require 'pry-nav' | |
array = ["1-28-2015 NYC LPEP $20.16", | |
"1-29-2015 DEN $17.06", | |
"1-30-2015 Aden Food Market $11.89", | |
"1-30-2015 ZIZI LIMONA $96.65", | |
"1-31-2015 FOODTOWN $67.49", | |
"2-4-2015 NYC-TAXI $15.96", | |
"2-4-2015 DRAM $21.00", | |
"2-4-2015 BALTHAZAR $42.40", | |
"2-5-2015 DINER $31.13", | |
"2-7-2015 DOTORY $23.60", | |
"2-7-2015 ZABLOZKIS BAR $13.00", | |
"2-8-2015 CENTER WORLD CAR SVCE $7.56", | |
"2-8-2015 ADEN FOOD MARKET $26.50", | |
"2-8-2015 NYC-TAXI $14.00", | |
"2-8-2015 MARLOW AND SONS WINE $18.24", | |
"2-8-2015 PEGU $54.73", | |
"2-9-2015 SQ SUMMERS JUICE & CO $6.00", | |
"2-9-2015 DUANE READE #14426 $10.49", | |
"2-9-2015 SQ SUMMERS JUICE & CO $18.00", | |
"2-9-2015 LE PAIN QUOTIDIEN $19.93", | |
"2-9-2015 ID COED, INC. $69.00", | |
"2-10-2015 SQ SUMMERS JUICE & CO $11.50", | |
"2-10-2015 DUANE READE #14426 $766.53", | |
"2-10-2015 DINER $31.13"] | |
newa = array.collect do |element| | |
match = element.match(/(\d+\-\d+\-\d+) (.*?) (\$.*)$/) | |
[match[1], match[2], match[3]] | |
end | |
newa.each do |element| | |
puts element[0] | |
end | |
newa.each do |element| | |
puts element[1] | |
end | |
newa.each do |element| | |
puts element[2] | |
end | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment