I have some code that iterates through 'Documents' in couchDB
for docid in db:
test = db.get(docid)
try:
type = test['type']
except:
type = "dontTestMe"
if type == 'file':
fileName = test['AliasName']
fileID = test['fileid']
testName = None
if type == 'job':
testName = test['testname']
stStart = time.strptime(time.ctime(test['teststart']))
stStop = time.strptime(time.ctime(test['testfinish']))
difStart = datetime.datetime(stStart.tm_year, stStart.tm_mon, stStart.tm_mday, stStart.tm_hour, stStart.tm_min, stStart.tm_sec)
difStop = datetime.datetime(stStop.tm_year, stStop.tm_mon, stStop.tm_mday, stStop.tm_hour, stStop.tm_min, stStop.tm_sec)
diff = difStop - difStart
print fileName, testName, diff
My result is
Filename Test1 DurationOfTest
Filename Test2 DurationOfTest
Filename Test3 DurationOfTest
etc...
What I want is
FileName Test1 Duration Test2 Duration Test3 Duration etc...
开发者_JS百科How do I go about doing that?
print fileName, testName, diff,
notice the trailing ,
精彩评论