概要
wsl(wsl2じゃない)でledgerやってみた。
練習問題、やってみた。
csv読んでみた。
練習問題
弥生会計のエクスポートしたcsvを、elixirでledgerが読めるように変換せよ。
サンプルコード
defmodule Main do
def main() do
csv = """
"2000",139,"","H.21/01/23","普通預金","みずほ銀行","","対象外",842,0,"受取利息","","","非課売上",842,0,"","","",0,"","","0","0","no"
"2000",142,"","H.21/01/31","普通預金","みずほ銀行","","対象外",388500,0,"売上高","","","課税売上込",388500,0,"商品販売","","",0,"","","0","0","no"
"2000",225,"","H.21/02/14","水道光熱費","","","課対仕入込",2046,0,"現金","","","対象外",2046,0,"電気料金","","",0,"","","0","0","no"
"2000",226,"","H.21/02/15","通信費","","","課対仕入込",1501,0,"現金","","","対象外",1501,0,"電話料金","","",0,"","","0","0","no"
"2000",227,"","H.21/02/16","水道光熱費","","","課対仕入込",1058,0,"現金","","","対象外",1058,0,"水道料金","","",0,"","","0","0","no"
"2000",87,"","H.21/02/17","消耗品費","","","課対仕入込",980,0,"現金","","","対象外",980,0,"事務商品購入","","",0,"","","0","0","no"
"2000",112,"","H.21/02/22","旅費交通費","","","課対仕入込",4730,0,"現金","","","対象外",4730,0,"通勤定期代","","",0,"","","0","0","no"
"""
Enum.map(String.split(csv, "\n"), fn l ->
print(l)
end)
end
def print(nil) do
IO.puts "ok"
end
def print(l) do
s = String.split(l, ",")
IO.puts "#{Enum.at(s, 3)} #{Enum.at(s, 4)} #{Enum.at(s, 8)} #{Enum.at(s, 10)} #{Enum.at(s, 14)}"
end
end
Main.main
実行結果
"H.21/01/23" "普通預金" 842 "受取利息" 842
"H.21/01/31" "普通預金" 388500 "売上高" 388500
"H.21/02/14" "水道光熱費" 2046 "現金" 2046
"H.21/02/15" "通信費" 1501 "現金" 1501
"H.21/02/16" "水道光熱費" 1058 "現金" 1058
"H.21/02/17" "消耗品費" 980 "現金" 980
"H.21/02/22" "旅費交通費" 4730 "現金" 4730
成果物
以上。