Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Feb 22nd, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #!/usr/bin/python
  2. # Open a file
  3.  
  4. import re
  5. import os
  6. import sys
  7. import glob
  8.  
  9. outfile = open("list7.txt", "w")
  10.  
  11. # This would print all the files and directories (in sorted order)
  12. full_path = r"F:fileslist"
  13. filelist = sorted(os.listdir( full_path ))
  14. print filelist
  15.  
  16. # This would scan the filelist and extract desired line that located between two rovs:
  17. # 00001q1.txt:
  18. # Row above line
  19. # line
  20. # Row under line
  21.  
  22. buffer = []
  23. for line in filelist:
  24.     if line.startswith("Row above line"):
  25.         buffer = ['']
  26.     elif line.startswith("Row under line"):
  27.         outfile.write("".join(buffer))
  28.         buffer = []
  29.     elif buffer:
  30.         buffer.append(line)
  31.  
  32. # infile.close()
  33. outfile.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top