有一些记帐的交易记录,请教下各位大佬,用 vim 可以处理吗?还是用 python3 处理比较合适?
# 数据的字段如下
日期 /科目名 /编号 /描述 /Full Category Path/对账 /Amount With Sym/Amount Num./Rate/Price
# 案例 1
2014-08-09/Liabilities:ShortTerm:CreditCard:CGB//by Ali Transfer/Assets:DebitCard:CEB:8644/清 /CN¥1.00/1.00/1.00
# 案例 2
2014-12-22/Liabilities:ShortTerm:CreditCard:CGB///Expenses:ManagementFee:OfficeAllowance:Groceries/清 /-CN¥23.60/-23.60/1.00
# 案例 3
2014-12-19/Liabilities:ShortTerm:CreditCard:CGB///Expenses:ManagementFee:Travelling:Public-TAXI/清 /CN¥96.00/96.00/1.00
# 希望处理后的格式如下:
日期 ! "描述"
[tab]科目名[tab]Amount Num
[tab]科目名
# Amount Num 格式:100.00 CNY
# 不需要“对账”字段
# 不需要 rate 字段
# 不需要 price 字段
# 实例 1
2014-08-09 ! "by Ali Transfer"
Liabilities:ShortTerm:CreditCard:CGB 1.00 CNY
Assets:DebitCard:CEB:8644
# 实例 2
2014-12-22 ! ""
Liabilities:ShortTerm:CreditCard:CGB -23.60 CNY
Expenses:ManagementFee:OfficeAllowance:Groceries
# 实例 3
2014-12-19 ! ""
Liabilities:ShortTerm:CreditCard:CGB 96.00 CNY
Expenses:ManagementFee:Travelling:Public-TAXI
万分感谢!!!可适当有偿小红包
1
xzc19970719 2019-07-05 00:38:32 +08:00 via Android
vim 是个编辑器 Python 是门语言 。。这两个怎么比较??
|
2
2067 2019-07-05 00:43:02 +08:00
我觉着你可能想问的是,用 awk 能处理吗,答案是可以
用 print { "xxxx" $xx "xxxx" $xx }这样的方法就可以 |
3
2067 2019-07-05 00:43:40 +08:00
另外注意一下分隔符是 /
|
4
Tony042 2019-07-05 00:50:09 +08:00
Beancount 自带 importer,用个写几个 python 类就解决了自动解析的需求,https://github.com/beancount/smart_importer
|