Created
April 17, 2019 13:31
-
-
Save edwardtoday/400863fcd393fd999175d5ba19861d3e to your computer and use it in GitHub Desktop.
lizard结果分析
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
# -*- coding: utf-8 -* | |
import csv | |
# 解析文件,得到函数行数的列表 | |
def get_len_arr(filename='result.csv'): | |
arr = [] | |
with open(filename) as fp: | |
# 获取头部(返回一个元祖) | |
print(next(fp)) | |
for row in csv.reader(fp): | |
arr.append(int(row[4])) | |
if int(row[4]) > 50: | |
print(','.join(row)) | |
return arr | |
# 根据函数长度列表的出结果 | |
def parse_arr(arr): | |
n, m = 0, len(arr) | |
if m > 0: | |
for i in arr: | |
n = n + 1 if i <= 50 else n | |
print('\r\npercent:{0} ({1}/{2})'.format( | |
format(n / float(m), '.2%'), n, m)) | |
if __name__ == '__main__': | |
parse_arr(get_len_arr()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment