Zunächst habe ich den Code so aufgebaut:
Code: Alles auswählen
def reading_datasets(filepath): #reading the required datasets
file = open(filepath,"r")
targetlist = []
for line in file:
if line[0:3]=='smi': #check if line begins with 'smi'
targetlist.append(line) #to identify the required datasets
file.close()
return targetlist
Code: Alles auswählen
for line in file
Code: Alles auswählen
def reading_datasets(filepath): #reading the required datasets
file = open(filepath,"r")
targetlist = []
while file.readline():
line = file.readline()
if line[0:3]=='smi': #check if line begins with 'smi'
targetlist.append(line) #to identify the required datasets
file.close()
return targetlist