读取“-1 000,00”等csv号时出错

时间:2018-03-11 08:07:26

标签: python csv

当我尝试读取“-1 000,00”等数字时,我感到非常恐怖。 结果是'-1 \ xa0000,00'。

如何修复我的代码以清除错误?

def read_csv(filename):
    list = []
    with open(filename, 'r', encoding='utf-8') as local_file:
        fields = ['Account_group_name',
                  'Current_balance',
                  'Account_name',
                  'Transfer_account_name',
                  'Description',
                  'Partner_name',
                  'Category',
                  'Date',
                  'Time',
                  'Memo',
                  'Sum',
                  'Currency',
                  'Face_balance',
                  'Balance',
                  ]
        reader = csv.DictReader(local_file, fields, delimiter=';')
        next(reader)
        for row in reader:
            list.append(row)
    return list

0 个答案:

没有答案