Skip to content

Instantly share code, notes, and snippets.

@tlatsas
Created May 21, 2013 08:37
Show Gist options
  • Save tlatsas/5618367 to your computer and use it in GitHub Desktop.
Save tlatsas/5618367 to your computer and use it in GitHub Desktop.
reports timelapse
#!/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