subset from text file and iterate

4 views
Skip to first unread message

krishnasaibn

unread,
Apr 17, 2019, 1:10:51 AM4/17/19
to Lamp_tutorial
Hi all, 
    Need some help in python

   I have a text file which have content with sub headings like Notes, Detailed Notes,Additional Notes order doesn't follow
 I need to subset from Notes to detailed Notes and i need to push temp file  for further operation to continue and the next 
it should take next subset from detailed Notes to Additional Notes like wise it go on till end of file

krishnasaibn

unread,
Apr 17, 2019, 1:46:31 AM4/17/19
to Lamp_tutorial
This is my code actually this starts with Note but how to break at 2nd occurence

    with open(file,encoding='utf8') as in_file: 
        s = in_file.read() 
        
        for i, char in enumerate(): 
            if s[i:i+10] == 'Note': 
                break                   
        for j in range(i,0,-1): 
            if s[j] == '\n': 
                break            
        rest_of_file = s[j+1:] 
  
Reply all
Reply to author
Forward
0 new messages