using csv dictreader in python

2009-11-04 Thread Siva Subramanian
Hello all,

I am now trying to access the csv file using dictreader.

import csv

r25  = csv.DictReader(open('Report_
25', 'rb'), delimiter=',')

rownum = 1
for row in r25:
# Save header row.
if rownum == 0:
header = row
else:
colnum = 0
for col in row:

This only gets me the following output

{'FieldName1': '4', 'FieldName2': '0.00', 'FieldName3':
'4001433', 'FieldName4': '759'}

1. How do i access the 4, 0.00, ... the values ?
2. How do i compare it with another csv file ?

Thanks in advance
Siva
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using csv dictreader in python

2009-11-04 Thread Johann Spies
On Wed, Nov 04, 2009 at 01:25:16PM +0530, Siva Subramanian wrote:

 This only gets me the following output
 
 {'FieldName1': '4', 'FieldName2': '0.00', 'FieldName3':
 '4001433', 'FieldName4': '759'}
 
 1. How do i access the 4, 0.00, ... the values ?

 a= {'FieldName1': '4', 'FieldName2': '0.00', 'FieldName3': '4001433', 
 'FieldName4': '759'}
 a
{'FieldName4': '759', 'FieldName1': '4', 'FieldName3': '4001433', 'FieldName2': 
'0.00'}
 a['FieldName3']
'4001433'

 2. How do i compare it with another csv file ?

If you have the values in one file, get the values in the other one
and then compare.  I am not sure I understand what is the problem here.

Regards
Johann
-- 
Johann Spies  Telefoon: 021-808 4599
Informasietegnologie, Universiteit van Stellenbosch

 Train up a child in the way he should go: and when he
  is old, he will not depart from it.   Proverbs 22:6 
-- 
http://mail.python.org/mailman/listinfo/python-list