Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- start = "SUMMARY BY SITE"
- filepath = '/Users/shaunstone/Downloads/FILE.txt'
- out_file = open("output.csv", "w+")
- started = 0
- with open(filepath) as fp:
- line = fp.readline()
- cnt = 1
- while line:
- line = fp.readline()
- if line.startswith(start):
- started = 1
- if started == 1:
- if (line.startswith("----- ")):
- started = 2
- continue
- if started == 2:
- if not line.strip() or line == "" or line.startswith("--"):
- line = False
- else:
- out_file.write(' '.join(line.split()).replace(' ', ','))
- out_file.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement