Re: Dictionaries and loops

2008-09-08 Thread Bruno Desthuilliers
Mike P a écrit : 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 = op

Re: Dictionaries and loops

2008-09-08 Thread Mike P
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"

Re: Dictionaries and loops

2008-09-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Bruno Desthuilliers: This doesn't look like a CSV file at all... Is that what you actually have in the file, or what you get from the csv.reader ??? I presume you are right, the file probably doesn't contain that stuff like I have assumed in my silly/useless solutio

Re: Dictionaries and loops

2008-09-08 Thread bearophileHUGS
Bruno Desthuilliers: > This doesn't look like a CSV file at all... Is that what you actually > have in the file, or what you get from the csv.reader ??? I presume you are right, the file probably doesn't contain that stuff like I have assumed in my silly/useless solutions :-) Bye, bearophile -- h

Re: Dictionaries and loops

2008-09-08 Thread bearophileHUGS
Few solutions, not much tested: data = """{None: ['User-ID', 'Count']} {None: ['576460847178667334', '1']} {None: ['576460847178632334', '8']}""" lines = iter(data.splitlines()) lines.next() identity_table = "".join(map(chr, xrange(256))) result = {} for line in lines: parts = line.translate

Re: Dictionaries and loops

2008-09-08 Thread Bruno Desthuilliers
Mike P a écrit : Hi All i have a CSV file that i'm reading in and each line has the look of the below {None: ['User-ID', 'Count']} {None: ['576460847178667334', '1']} {None: ['576460847178632334', '8']} This doesn't look like a CSV file at all... Is that what you actually have in the file, or

Dictionaries and loops

2008-09-08 Thread Mike P
Hi All i have a CSV file that i'm reading in and each line has the look of the below {None: ['User-ID', 'Count']} {None: ['576460847178667334', '1']} {None: ['576460847178632334', '8']} i want to make a dictionary of items in the form {576460847178667334:1, 576460847178632334:8, . } for all r