Skip to content

Instantly share code, notes, and snippets.

@geudrik
Last active September 5, 2015 19:07
Show Gist options
  • Save geudrik/6fa10f6fbd1c0fe5577e to your computer and use it in GitHub Desktop.
Save geudrik/6fa10f6fbd1c0fe5577e to your computer and use it in GitHub Desktop.
Find rows in a CobbAP Datalog that indicate non-nominal values for DAM, FK, and FKL
#! /usr/bin/env python2.7
# Written by Pat Litke
# This is a total hack to indicate sections in a large Cobb AP datalog that need review
# Specifically, this script dumps out those sections where DAM, FK, and/or FKL are non-nominal
import csv
import sys
CSVRowNumber = 2 # Row 2 is the first row of data
CSVRowNumberList = []
if len(sys.argv) != 2:
print "Usage: {0} /path/to/CobbAP/DataLog/CSV".format(sys.argv[0])
sys.exit(1)
with open(sys.argv[1], 'r') as handle:
reader = csv.DictReader(handle, delimiter=',')
# Skip our headers
next(reader, None)
# Search for DAM and Knock values are not nominal
for row in reader:
# Positions 7, 8, and 9 are DAM, FK, FKL
if row['Dyn. Adv. Mult (DAM)'] != "1.000":
#print "[ ] Non Nominal DAM Value at Row {0}".format(CSVRowNumber)
#CSVRowNumberList.append(CSVRowNumber)
# Ignore DAM this time around as the logs I'm reviewing never had an optimal DAM
pass
if row['Feedback Knock (\xb0)'] != "0.00" or row['Fine Knock Learn (\xb0)'] != "0.00":
print "[ ] Non Nominal FK or FKL Value at Row {0}".format(CSVRowNumber)
CSVRowNumberList.append(CSVRowNumber)
CSVRowNumber += 1
# Loop over our linecountList var, and look for elements (line numbers) that are non-sequential
# A non-sequential line number indicates a new section for review
for i in CSVRowNumberList:
# Check if index(i)+1 is sequential. If yes, skip
try:
# Check the previous index. If the value of the previous index is one away (in sequence)
# no new section has been found. If the jump between the previous value and this valus is >1
# a new section has been found
# If this index does not equal the previous index plus 1, we found a new sequence of badness
if i != (CSVRowNumberList[CSVRowNumberList.index(i) - 1] + 1):
print "New section of non-nominal results begins at row {0}".format(i)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment