I am trying to extract the lines that start with this entries and create a new file. This is what I have:
def ReadFileContents():
file_content = open('Testing.pdb')
all_file_content = file_content.readlines()
list3 = []
for line in all_file_content:
if line.startswith('TER'):`enter code here`
list3.append(line)
if line.startswith('HETATM'):
list3.apped(line)
if line.startswith('CONECT'):
list3.append(line)
if line.startswith('MASTER'):
list3.append(line)
if line.startswith('END'):
list3.append(line)
file = open('list3.txt', 'w')
for line in list3:
file.write(line + '\n')
file.close()
ReadFileContents()
The problem is that only creates the list3.txt file with the lines that start with TER. Any ideas why?
Thanks, Pedro
Spaces in the beginning of the line denote a code block level in python. Suppose you have the following code:
another thing
will be done only if A condition isTrue
.