66
77
88def change_datatype (row_data : list ):
9- """
10- excel单元格的内容类型检测和转换
11- 参数:
12- row_data:行数据,列表格式
9+ """Excel单元格的内容类型检测和转换。
10+
11+ Args:
12+ row_data (list): 行数据,列表格式
13+
14+ Returns:
15+ list: 转换后的行数据
1316 """
1417 result_data = []
1518 for rd in row_data :
@@ -30,11 +33,14 @@ def change_datatype(row_data: list):
3033
3134
3235def find_key (search_key : str , row_content : str ):
33- """
34- 检测关键词和内容
35- 参数:
36- search_key:关键词
37- row_content:行内容
36+ """检测关键词和内容。
37+
38+ Args:
39+ search_key (str): 关键词
40+ row_content (str): 行内容
41+
42+ Returns:
43+ bool: 如果包含关键词返回True,否则返回False
3844 """
3945 if search_key in row_content :
4046 return True
@@ -43,11 +49,14 @@ def find_key(search_key: str, row_content: str):
4349
4450
4551def process_xls (path , file ):
46- """
47- 读取xls后缀的excel文件
48- 参数:
49- path:文件所在路径
50- file:文件名
52+ """读取xls后缀的Excel文件。
53+
54+ Args:
55+ path (str): 文件所在路径
56+ file (str): 文件名
57+
58+ Yields:
59+ tuple: 包含文件路径、工作表名、行数、行内容的元组
5160 """
5261 filepath = os .path .join (path , file )
5362 try :
@@ -74,11 +83,14 @@ def process_xls(path, file):
7483
7584
7685def process_xlsx (path , file ):
77- """
78- 读取xlsx后缀的excel文件
79- 参数:
80- path:文件所在路径
81- file:文件名
86+ """读取xlsx后缀的Excel文件。
87+
88+ Args:
89+ path (str): 文件所在路径
90+ file (str): 文件名
91+
92+ Yields:
93+ tuple: 包含文件路径、工作表名、行数、行内容的元组
8294 """
8395 filepath = os .path .join (path , file )
8496 try :
@@ -103,11 +115,14 @@ def process_xlsx(path, file):
103115
104116
105117def find_excel_data (search_key : str , target_dir : str ):
106- """
107- 检索指定目录下的excel文件和过滤
108- 参数:
109- search_key:检索的关键词
110- target_dir:目标文件夹
118+ """检索指定目录下的Excel文件和过滤。
119+
120+ Args:
121+ search_key (str): 检索的关键词
122+ target_dir (str): 目标文件夹
123+
124+ Yields:
125+ tuple: 包含文件路径、工作表名、行数、行内容的元组
111126 """
112127 for path , dirs , files in os .walk (target_dir ):
113128 files = [file for file in files if not file .startswith ('~$' )] # 过滤掉正打开的excel文件
0 commit comments