expanded data cleaning command
This commit is contained in:
BIN
SpdCoach-2136923-2010-02-01-20-46-22o.csv.gz
Normal file
BIN
SpdCoach-2136923-2010-02-01-20-46-22o.csv.gz
Normal file
Binary file not shown.
@@ -42,6 +42,23 @@ if settings.DEBUG or user=='':
|
|||||||
database_url = 'sqlite:///'+database_name
|
database_url = 'sqlite:///'+database_name
|
||||||
|
|
||||||
|
|
||||||
|
columndict = {
|
||||||
|
'time':'TimeStamp (sec)',
|
||||||
|
'hr':' HRCur (bpm)',
|
||||||
|
'pace':' Stroke500mPace (sec/500m)',
|
||||||
|
'spm':' Cadence (stokes/min)',
|
||||||
|
'power':' Power (watts)',
|
||||||
|
'averageforce':' AverageDriveForce (lbs)',
|
||||||
|
'drivelength':' DriveLength (meters)',
|
||||||
|
'peakforce':' PeakDriveForce (lbs)',
|
||||||
|
'distance':' Horizontal (meters)',
|
||||||
|
'catch':'catch',
|
||||||
|
'finish':'finish',
|
||||||
|
'peakforceangle':'peakforceangle',
|
||||||
|
'wash':'wash',
|
||||||
|
'slip':'wash',
|
||||||
|
}
|
||||||
|
|
||||||
from scipy.signal import savgol_filter
|
from scipy.signal import savgol_filter
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
@@ -267,23 +284,39 @@ def compare_data(id):
|
|||||||
print "Database Locked"
|
print "Database Locked"
|
||||||
conn.close()
|
conn.close()
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
return l1==l2
|
lfile = l1
|
||||||
|
ldb = l2
|
||||||
|
return l1==l2,ldb,lfile
|
||||||
|
|
||||||
def repair_data(verbose=False):
|
def repair_data(verbose=False):
|
||||||
ws = Workout.objects.all()
|
ws = Workout.objects.all()
|
||||||
for w in ws:
|
for w in ws:
|
||||||
if verbose:
|
if verbose:
|
||||||
sys.stdout.write(".")
|
sys.stdout.write(".")
|
||||||
if not compare_data(w.id):
|
test,ldb,lfile = compare_data(w.id)
|
||||||
|
if not test:
|
||||||
if verbose:
|
if verbose:
|
||||||
print w.id
|
print w.id,lfile,ldb
|
||||||
try:
|
try:
|
||||||
rowdata = rdata(w.csvfilename)
|
rowdata = rdata(w.csvfilename)
|
||||||
if rowdata:
|
if rowdata:
|
||||||
update_strokedata(w.id,rowdata.df)
|
update_strokedata(w.id,rowdata.df)
|
||||||
except IOError, AttributeError:
|
except IOError, AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if not lfile:
|
||||||
|
try:
|
||||||
|
data = read_df_sql(w.id)
|
||||||
|
data.rename(columns = columndict,inplace=True)
|
||||||
|
res = data.to_csv(w.csvfilename+'.gz',
|
||||||
|
index_label='index',
|
||||||
|
compression='gzip')
|
||||||
|
print 'adding csv file'
|
||||||
|
except:
|
||||||
|
print 'failed'
|
||||||
|
print str(sys.exc_info()[0])
|
||||||
|
pass
|
||||||
|
|
||||||
def rdata(file,rower=rrower()):
|
def rdata(file,rower=rrower()):
|
||||||
try:
|
try:
|
||||||
res = rrdata(file,rower=rower)
|
res = rrdata(file,rower=rower)
|
||||||
|
|||||||
Reference in New Issue
Block a user