Last active
December 16, 2015 22:39
-
-
Save jbrechtel/5508848 to your computer and use it in GitHub Desktop.
T&E
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 'rubygems' | |
require 'csv' | |
require 'json' | |
require 'pp' | |
data = CSV.parse(File.read(ARGV[0])) | |
cols = data.shift | |
hashes = data.map { |v| cols.zip(v) }.map { |a| Hash[*a.flatten] } | |
puts 'var e = '+hashes.to_json |
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
e.each(function(item, index) { | |
var amountInput = $$('#activities_0_items_'+index+'_amount')[0]; | |
var dateInput = $$('#activities_0_items_'+index+'_item_date_string')[0]; | |
var descInput = $$('#activities_0_items_'+index+'_description')[0]; | |
var vendorInput = $$('#activities_0_items_'+index+'_vendor')[0]; | |
var categoryInput = $$('#activities_0_items_'+index+'_category')[0]; | |
var paymentInput = $$('#activities_0_items_'+index+'_payment')[0]; | |
var attendeeInput = $$('#activities_0_items_'+index+'_attendees')[0]; | |
dateInput.value = item['Timestamp']; | |
amountInput.value = item['Amount']; | |
descInput.value = item['Comment']; | |
vendorInput.value = item['Merchant']; | |
categoryInput.value = 'EXPBMEAL'; | |
paymentInput.value = 'PMTPERS'; | |
attendeeInput.value = 'me'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment