convert string number to real number - ValueError: invalid literal for int() with base 10: '"2"'

David Jackson davidj411 at gmail.com
Tue May 27 12:00:05 EDT 2008


i used the csv module and saved its contents to a list.

['Date', 'No.', 'Description', 'Debit', 'Credit']
['3/17/2006', '5678', 'ELECTRONIC PAYMENT', '', '11.45']
['3/04/2007', '5678', 'THE HOME DEPOT 263 SomeCity FL', '', '25.40']


the credit/debit fields are strings.
what should i have done within the CSV module to make numbers appear as
numbers?
how can i remove the quotes to make them numbers? i realize i posted a
solution to this once before (same posting thread) but i am thinking there
is a better method.



On Thu, Feb 28, 2008 at 7:19 PM, D'Arcy J.M. Cain <darcy at druid.net> wrote:

> On Thu, 28 Feb 2008 14:56:10 -0800 (PST)
> davidj411 <davidj411 at gmail.com> wrote:
> > ValueError: invalid literal for int() with base 10: '"2"'
> >
> >
> > here is the question:
> >
> > How can i convert a string number like "2" to a true number that can
> > be added.
>
> You have to get rid of the double quotes first.
>
> --
> D'Arcy J.M. Cain <darcy at druid.net>         |  Democracy is three wolves
> http://www.druid.net/darcy/                |  and a sheep voting on
> +1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080527/b1d0fe3c/attachment.html>


More information about the Python-list mailing list