Help with exporting data from LDAP

I have the below script to extract data from ldap. Python version is 2.7. However I am not able to write the contents to a csv file. Any help is appreciated.

import csv
import ldap
host = ‘ldap://’
dn = ‘dddddddd’
pw = ‘xxxxxxx’
base_dn = ‘ou=People,,o=razor’
filter = ‘(objectclass=*)’
attrs = [‘idnumber’,‘emnumber’,‘givenname’,‘mail’]
con = ldap.initialize( host )

Bind to the server

con.simple_bind_s( dn, pw )

res = con.search_s( base_dn, ldap.SCOPE_SUBTREE, filter, attrs )

Close the connection


Print the returned dictionary

#print res

for i in row_list:
print i[1]