SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. start = "SUMMARY BY SITE"
  4. filepath = '/Users/shaunstone/Downloads/FILE.txt'
  5. out_file = open("output.csv", "w+")
  6. started = 0
  7. with open(filepath) as fp:
  8.     line = fp.readline()
  9.     cnt = 1
  10.     while line:
  11.         line = fp.readline()
  12.         if line.startswith(start):
  13.             started = 1
  14.         if started == 1:
  15.             if (line.startswith("----- ")):
  16.                 started = 2
  17.                 continue
  18.         if started == 2:
  19.             if not line.strip() or line == "" or line.startswith("--"):
  20.                 line = False
  21.             else:
  22.                 out_file.write(' '.join(line.split()).replace(' ', ','))
  23.                 out_file.write('\n')
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top