Last active
November 28, 2018 22:20
-
-
Save ssp/db6d14d485720a561f5b3eaf824f28d2 to your computer and use it in GitHub Desktop.
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
# alle Dateien, deren Name auf _B endet … | |
find . -name "*_B" -print0 | xargs -0 ./reduce.py > processed.csv | |
# erster Versuch mit Pipes | |
cat 20181011_06-04-51_B \ | |
| awk 'NR == 1 || NR == 2 || NR % 100 == 0' \ | |
| sed -e 's/ \+/ /g' \ | |
| cut -d ' ' -f 1-10 \ | |
> 20181011_06-04-51_B-reduced |
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 re | |
import datetime | |
import time | |
import sys | |
dateFormat = '%Y%m%d_%H-%M-%S' | |
def processFile(path): | |
dateString = re.sub('.*(\d\d\d\d\d\d\d\d_\d\d-\d\d-\d\d).*' , '\\1', path) | |
startTime = datetime.datetime.strptime(dateString, dateFormat) | |
startTimestamp = time.mktime(startTime.timetuple()) | |
with open(path, "r") as inputFile: | |
linenumber = 0 | |
for line in inputFile: | |
linenumber += 1 | |
if linenumber % 100 == 0: | |
singlespaces = re.sub('\n', '', re.sub(r' +', ' ', line)) | |
columns = singlespaces.split(' ') | |
currentTimestamp = float(startTimestamp) + float(columns[0]) | |
result = [str(int(currentTimestamp))] + columns | |
print(' '.join(result)) | |
fileNames = sys.argv[1:] | |
for fileName in fileNames: | |
processFile(fileName) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment