On Tue, Nov 5, 2013 at 3:44 PM, hari prasadh <[email protected]> wrote:
> As iam new to python,please help here.
>
>
> [root@10 ~]# cat /tmp/acess_Nov5_1.csv
>
> "1","88"
>
> "1","89"
>
> "1","95"

As Noorul stated, empty lines can cause issues.

>>>> import csv
>
>>>> ifile  = open('/tmp/acess_Nov5_1.csv', "rb")
>
>>>> reader = csv.reader(ifile)
>
>>>> 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
>
>>>> 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

Reply via email to