Last active
December 15, 2015 08:49
-
-
Save stringsn88keys/5233456 to your computer and use it in GitHub Desktop.
Translation of Betterment format to Drake software format (as documented, then as discovered.)
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
# This is the layout that Drake had documented (coming from Betterment format) | |
oldLayoutJustForReference = <<-LAYOUT | |
0,TSJ,"T" | |
1,F,"" | |
2,State,"" | |
3,City,"" | |
4,Date Sold (MMDDYYYY),column[:f] | |
5,Date Acquired (MMDDYYYY),column[:e] | |
6,Proceeds,column[:g] | |
7,Cost,column[:h] | |
8,Fed W/H,column[:k] | |
9,Wash Sale,column[:j] | |
10,Type,column[:l][0] | |
11,Description,column[:a] | |
12,Loss Not Allowed,"" | |
13,Basis Not Reported,"" | |
14,Adj 1 Code,"" | |
15,Adj 1,"" | |
16,Adj 1 AMT,"" | |
17,Adj 2 Code,"" | |
18,Adj 2,"" | |
19,Adj 2 AMT,"" | |
20,Adj 3 Code,"" | |
21,Adj 3,"" | |
22,Adj 3 AMT,"" | |
23,AMT Cost Basis,"" | |
24,US Real Property sold by nonresident,"" | |
LAYOUT | |
# This is the layout inferred from the bad import by Drake. | |
# Drake column | |
betterment_to_drake_layout = <<-LAYOUT | |
0,TSJ,"T" | |
1,F,"" | |
2,State,"" | |
3,City,"" | |
4,Sold,data[:f] | |
5,Acquired,data[:e] | |
6,Short/Long,data[:l][0] | |
7,Symbol,data[:b] | |
8,Quantity,data[:c] | |
9,Proceeds,data[:g] | |
10,Loss Not Allowed,"" | |
11,Cost,data[:h] | |
12,Fed W/H,data[:k] | |
13,Wash Sale,data[:j] | |
14,Description,data[:a] | |
LAYOUT | |
titles = [] | |
layout = [] | |
betterment_to_drake_layout.each_line do |line| | |
column, title, value = line.split ',' | |
titles[column.to_i] = title | |
layout[column.to_i] = value.chomp | |
end | |
ARGF.each_line do |line| | |
data=Hash[(:a..:m).to_a.zip(line.split ',')] | |
puts layout.map {|x| eval(x)}.join(',') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment