-
Notifications
You must be signed in to change notification settings - Fork 7
/
auto_statistics.py
43 lines (33 loc) · 1012 Bytes
/
auto_statistics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# coding=utf-8
"""
paper 统计
"""
import os
files_list = os.listdir('./')
markdown_files_list = list()
for file in files_list:
if os.path.splitext(file)[1] == '.md':
markdown_files_list.append(file)
markdown_files_list.remove('README.md')
markdown_files_list.remove('模板.md')
statistic_info = list()
all_papers_count = 0
for file in markdown_files_list:
file_name = os.path.splitext(file)[0]
f = open(file, 'r', encoding='UTF-8')
lines = f.readlines()
papaper_count = 0
for line in lines:
table_elements = line.split('|')
for element in table_elements:
element = element.strip()
if element.startswith('《') and element.endswith('》'):
papaper_count += 1
all_papers_count += 1
break
f.close()
file_info = {file_name: papaper_count}
statistic_info.append(file_info)
for item in statistic_info:
print(item)
print('all papers count: {}'.format(all_papers_count))