Dictionaries and loops
Mike P
michael.pearmain at tangozebra.com
Mon Sep 8 11:14:01 EDT 2008
Thanks for the solution above,
The raw data looked like
User-ID,COUNTS
576460840144207854,6
576460821700280307,2
576460783848259584,1
576460809027715074,3
576460825909089607,1
576460817407934470,1
and i used
CSV_INPUT1 = "C:/Example work/Attr_model/Activity_test.csv"
fin1 = open(CSV_INPUT1, "rb")
reader1 = csv.DictReader((fin1), [], delimiter=",")
for row in reader1:
print row
with the following outcome.
{None: ['User-ID', 'COUNTS']}
{None: ['576460840144207854', '6']}
{None: ['576460821700280307', '2']}
{None: ['576460783848259584', '1']}
{None: ['576460809027715074', '3']}
{None: ['576460825909089607', '1']}
So i can see csv.reader is what i should have been using
Thanks for the help
More information about the Python-list
mailing list