I have a Text file as below:
Education:
askdjbnakjfbuisbrkjsbvxcnbvfiuregifuksbkvjb.iasgiufdsegiyvskjdfbsldfgd
Technical skills :
java,j2ee etc.,
work done:
oaugafiuadgkfjwgeuyrfvskjdfviysdvfhsdf,aviysdvwuyevfahjvshgcsvdfs,bvisdhvfhjsvjdfvshjdvhfjvxjhfvhjsdbvfkjsbdkfg
I would like to extract only the heading names such as Education,Technical Skills etc.
the code is :
with open("aks.txt") as infile, open("fffm",'w') as outfile:
copy = False
for line in infile:
if line.strip() == "Technical Skills":
copy =True
elif line.strip() == "Workdone":
copy = True
elif line.strip() == "Education":
copy = False
elif copy:
outfile.write(line)
fh = open("fffm.txt", 'r')
contents = fh.read()
len(contents)