Created
May 21, 2013 08:37
-
-
Save tlatsas/5618367 to your computer and use it in GitHub Desktop.
reports timelapse
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 python | |
import sys | |
def save_csv(lines, filename): | |
print(filename) | |
with open(filename, 'w') as f: | |
for line in lines: | |
f.write("{}\n".format(line)) | |
def main(datafile): | |
prefix = datafile.split('-')[0] | |
entries = [] | |
with open(datafile, 'r') as f: | |
for line in f: | |
line = line.rstrip('\n') | |
entries.append(line) | |
l = len(entries) | |
if l >= 2: | |
filename = "{}-{}-reports.csv".format(prefix, l) | |
save_csv(entries, filename) | |
return 0 | |
if __name__ == "__main__": | |
if len(sys.argv) == 2: | |
sys.exit(main(sys.argv[1])) | |
else: | |
print("Error: wrong input") | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment