Skip to content

Instantly share code, notes, and snippets.

@anddam
Last active January 3, 2017 10:27
Show Gist options
  • Select an option

  • Save anddam/33cbe7b7596437fcec8f70591dfd5b94 to your computer and use it in GitHub Desktop.

Select an option

Save anddam/33cbe7b7596437fcec8f70591dfd5b94 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Read all tsv files from passed folder and average lines 469:535, take index from file name
from sys import argv, exit
from os import listdir
from pandas import DataFrame, read_csv
from datetime import datetime
try:
path = argv[1]
files = listdir(path)
except IndexError:
print("Provide a folder path as argument")
exit(1)
except FileNotFoundError:
print("Path is not valid")
exit(2)
result = DataFrame(columns=['quota', 'E355S', 'E355P'])
for file in files:
print("Parsing file '%s'" % file)
timestamp = datetime.strptime(file[26:39], '%y%m%d-%H%M%S')
data = read_csv(path + file, sep=None, engine='python')
mean_serie = data[469:535].mean(axis=0)
# result[timestamp] = mean_serie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment