[Tutor] Parsing txt file
Dima Kulik
dexternet89 at mail.ru
Wed Aug 20 14:35:03 CEST 2014
Hi to all. I have a problem with parsing file.
I have txt file exported from AD and it has such structure:
DistinguishedName : CN=*** ,OU=*** ,OU=*** ,DC=*** ,DC=***,DC=***
GroupCategory : Distribution
GroupScope : Universal
Name : ****
ObjectClass : group
ObjectGUID : 0b74b4e2-aad1-4342-a8f4-2fa7763e1d49
SamAccountName : ****
SID : S-1-5-21-1801674531-492894223-839522115-16421
i need to export to file all stings which start from "Name"
I've tried to make little parser:
keywords = ['Name', 'Name:']
input_file=open("Mail_Groups.txt","r").readlines()
output_file=open("Out.txt","w")
for line in input_file:
for word in line.split():
if word in keywords:
output_file.write(line)
but the output is clear.
What the problem is? Can some one help me?
--
Dima Kulik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140820/bb8880c5/attachment.html>
More information about the Tutor
mailing list