Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Created December 8, 2018 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackn9ne/9f07b6a720142816ef6d184f22680b50 to your computer and use it in GitHub Desktop.
Save zackn9ne/9f07b6a720142816ef6d184f22680b50 to your computer and use it in GitHub Desktop.
detect = '#+BEGIN_SRC emacs-lisp :exports code'
detectend = '#+END_SRC'
infile = 'c:/Users/netkam/OneDrive - Peralta Community College District/org/1812.org'
outfile = open('C:/Users/netkam/AppData/Roaming/.emacs', 'w')
with open(infile) as input_data:
# Skips text before the beginning of the interesting block:
for line in input_data:
if line.strip() == detect: # Or whatever test is needed
break
# Reads text until the end of the block:
for line in input_data: # This keeps reading the file
if line.strip() == detectend:
break
# print line # Line is extracted (o
outfile.write(line)
# yield line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment