CSV and number formats

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Feb 1 02:23:16 EST 2015


On 01/02/2015 06:45, Frank Millman wrote:
> Hi all
>
> I downloaded some bank statements in CSV format with a view to providing an
> automated bank reconciliation feature for my accounting software.
>
> One of them shows the opening balance in an unusual format.
>
> Most transaction amounts are in the format '-00000031.23' or '+00000024.58'
>
> This can easily be parsed using decimal.Decimal().
>
> If the opening balance is positive, it appears as '+00000021.45'
>
> If it is negative, it appears as '+00000-21.45'
>
> Predictably, decimal.Decimal does not like this.
>
> Is this a recognised format, and is there a standard way of parsing it? If
> not, I will have to special-case it, but I would prefer to avoid that if
> possible.
>
> Thanks
>
> Frank Millman
>

I've never seen anything like it and have to believe that this is a bug, 
although I'd guess that the bank in question will claim it's a feature. 
You'll surely have to work around it whilst waiting for a reply to the 
"WTF do you think you're playing at?" question.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list