Skip to content

Instantly share code, notes, and snippets.

@anddam
Last active January 12, 2017 20:18
Show Gist options
  • Save anddam/35b501eb9905df735557b0995eb3a7b1 to your computer and use it in GitHub Desktop.
Save anddam/35b501eb9905df735557b0995eb3a7b1 to your computer and use it in GitHub Desktop.
Elevation E355P E355S
1 3491.0 1235.0
2 6022.0 1815.0
3 9775.0 2686.0
Elevation E355P E355S
1 20301.0 5844.0
2 33132.0 9127.0
3 31452.0 6537.0
#!/usr/bin/env python
from sys import argv, exit
from os import listdir, path
from pandas import DataFrame, read_csv, concat
from datetime import datetime
try:
folder = argv[1]
if folder[-1] == '/':
folder = folder[:-1]
files = listdir(folder)
except IndexError:
print("Provide a folder path as argument")
exit(1)
except FileNotFoundError:
print("Path is not valid")
exit(2)
start = 26
end = start + 13
result = []
for file in files:
timestamp = datetime.strptime(file[start:end], '%y%m%d-%H%M%S')
print("Parsing file '%s', %r" % (file, timestamp))
csv_path = path.join(folder, file)
data = read_csv(csv_path, index_col=0, sep=None, engine='python')
data.index.name = 'Elevation'
result.append(DataFrame(data.E355P + data.E355S * 0.12, columns=[timestamp]).T)
result = concat(result, axis=0)
result.index.name = 'Timestamp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment