En Tue, 27 May 2008 13:00:05 -0300, David Jackson <[EMAIL PROTECTED]> escribió:

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.

What do you want to do with those empty strings? Convert them to zeros? Suppose your list is named `rows`:

for i,row in enumerate(rows):
    if not i: continue # skip titles
    row[3] = float(row[3] or 0)
    row[4] = float(row[4] or 0)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to