Thanks.got it..exactly this is what i need.me too got the same.earlier got the key error and gave as int(key).It worked
On Tue, Nov 5, 2013 at 4:14 PM, prathika sundaramurthy < [email protected]> wrote: > Hi Hari, > Can you check if this is what you needed? As per your requirement this is > what I have understood. > ifile = open('/tmp/acess_Nov5_1.csv', "rb") > reader = csv.reader(ifile) > print 'Key--->value' > for i in reader: > if i: > print '%s--->%s'%(i[1],dict[int(i[1])]) > c2process > riskmgmt > portal > > > On Tue, Nov 5, 2013 at 4:10 PM, Guruprasad <[email protected]> wrote: > > > Pressed send a bit too early before completing the email. > > > > On Tue, Nov 5, 2013 at 4:07 PM, Guruprasad <[email protected]> wrote: > > > On Tue, Nov 5, 2013 at 3:44 PM, hari prasadh <[email protected]> > > wrote: > > >> > > >>>>> dict={88:'c2process',89:'riskmgmt',95:'portal'} > > > > > > 'dict' is a python built-in. Not a good idea to use it to name your > > variable. > > > So something like my_dict = {88:'c2process',89:'riskmgmt > > > > my_dict = {88:'c2process',89:'riskmgmt',95:'portal'} > > > > Quoting the rest of the email for the completeness of the answer. > > > > >>>>> for i in reader: > > >> > > >> ... print "dict["+i[1]+"]" > > > > > > print my_dict[int(i[1])] will convert the string in the 2nd column of > > > the csv file to an integer and use it as a key, since your dictionary > > > uses integers as keys. > > > > Thanks & Regards, > > Guruprasad. > > _______________________________________________ > > ILUGC Mailing List: > > http://www.ae.iitm.ac.in/mailman/listinfo/ilugc > > ILUGC Mailing List Guidelines: > > http://ilugc.in/mailinglist-guidelines > > > > > > -- > prathika sundaramurthy > _______________________________________________ > ILUGC Mailing List: > http://www.ae.iitm.ac.in/mailman/listinfo/ilugc > ILUGC Mailing List Guidelines: > http://ilugc.in/mailinglist-guidelines > -- Thanks & Regards, HariPrasadh _______________________________________________ ILUGC Mailing List: http://www.ae.iitm.ac.in/mailman/listinfo/ilugc ILUGC Mailing List Guidelines: http://ilugc.in/mailinglist-guidelines
