Skip to content

Instantly share code, notes, and snippets.

@edwardtoday
Created April 17, 2019 13:31
Show Gist options
  • Save edwardtoday/400863fcd393fd999175d5ba19861d3e to your computer and use it in GitHub Desktop.
Save edwardtoday/400863fcd393fd999175d5ba19861d3e to your computer and use it in GitHub Desktop.
lizard结果分析
# -*- 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