This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
motors-scanner-test-1 [2012/10/06 18:38] 85.218.109.130 |
motors-scanner-test-1 [2012/10/08 16:45] 85.218.109.130 |
||
---|---|---|---|
Line 25: | Line 25: | ||
# reading the scan log from a csv file | # reading the scan log from a csv file | ||
+ | |||
+ | lookup_key=' # IV' | ||
def lookup(dump): | def lookup(dump): | ||
+ | datalist=[] | ||
scan=open(dump, "rU") | scan=open(dump, "rU") | ||
next(scan) | next(scan) | ||
scanDict=csv.DictReader((line.replace('\0','') for line in scan), delimiter=',') | scanDict=csv.DictReader((line.replace('\0','') for line in scan), delimiter=',') | ||
for adict in scanDict: | for adict in scanDict: | ||
- | if adict.has_key(' # IV'): | + | if adict.has_key(lookup_key) and adict.get(lookup_key)!=None: |
- | data=adict.get(' # IV') | + | try: |
- | return data | + | datalist.append(int(adict.get(lookup_key))) |
+ | except: | ||
+ | pass | ||
+ | return sum(datalist) | ||
- | packets=int(lookup(lasted)) | + | packets=lookup(lasted) |
print 'packets', packets | print 'packets', packets | ||