谢谢大家的关注! 我的问题陈述是:使用开源库将.csv文件转换为.ofx文件。 我建议的解决方案是:使用csv2ofx python库将.csv文件转换为.ofx
csv文件的描述:My.csv文件包含以下列:
映射:我应用自定义映射(因为我有不同的列),如下所示:
from operator import itemgetter
mapping = {
'has_header': True,
'is_split': False,
'delimiter': ',',
'amount': itemgetter('Amount'),
'date': itemgetter('Settlement date'),
'symbol':itemgetter('Symbol'),
'type': itemgetter('Transaction type'),
'payee': itemgetter('Name'),
'notes': itemgetter('Commissions and fees'),
}
代码:我编写以下代码将.csv转换为.ofx
ofx = OFX(mapping)
records = read_csv('Cleaned1.csv')
groups = ofx.gen_groups(records)
trxns = ofx.gen_trxns(groups)
cleaned_trxns = ofx.clean_trxns(trxns)
data = utils.gen_data(cleaned_trxns)
content = it.chain([ofx.header(), ofx.gen_body(data), ofx.footer()])
TypeError Traceback (most recent call last)
<ipython-input-389-0d57618f3bd8> in <module>
1 with open('Cleaned_new.ofx', 'wb') as f:
----> 2 for line in IterStringIO(content):
3 print(line)
4 f.write(line)
TypeError: Parser must be a string or character stream, not NoneType
我真的很感谢你抽出时间来阅读我的问题,期待听到你的建议或解决方案。多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐