Created
          August 18, 2014 02:36 
        
      - 
      
 - 
        
Save trcook/eadc86ab302d6090dfa8 to your computer and use it in GitHub Desktop.  
    this will change directories as directed, open a file, match by a regex and then print out the results ot a file as directed
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #! #!/usr/bin/env python3 | |
| import io, os, re | |
| os.chdir('/Users/tom/Desktop/tmp') | |
| e=open('questiondb.xml','rt') | |
| search_string=e.read() | |
| e.close() | |
| outfile=open("out.txt",'w') | |
| matches=re.findall(r"(<item d2l_2p0:id=.*\n(.+?\n(?!</item))+?.*?questiontype(.*?\n)+?.*Multiple Choice\n(.*\n)+?.*/item>.*?\n)",search_string) | |
| for i in matches: | |
| outfile.write(i[0]) | |
| outfile.close() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment