zac_carl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, Need your help on this.I have data for some 2000 users in LDAP format and i want to convert it to a csv file : I am writing a perl script and able to split the column by "=" .So the first field i.e cn,ID ,citizenship, sn etc becomes the column and the values on the Right Hand Side should print under the column. Also, there are multiple RegisteredqWebSite. I want it print only once , with multiple values under the column Please share if you have any better ideas do this
cn=d273,ou=People,dc=mipddefg,dc=com ID= Citizenship=CL sn=perez Group=internt-user postalAddress= st= mail=abc@hotmail.com uid=abc postalCode=1234 givenName=mario RegisteredqWebSite= RegisteredqWebSite= RegisteredqWebSite= RegisteredqWebSite= RegisteredqWebSite=
Thanks, Zac

Replies are listed 'Best First'.
Re: LDAP data to csv
by keszler (Priest) on Sep 16, 2011 at 15:12 UTC

    The data shown appear to be from an LDIF file, so I'm guessing you want to read from the file rather than from an LDAP server. The steps would be:

    1. Open and read LDIF file
    2. Manipulate data
    3. Write CSV file

    I recommend using Net::LDAP::LDIF and Text::CSV_XS.

    Once you have some code written people here will be happy to help you debug it.