We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6336c39 commit 3e42f1eCopy full SHA for 3e42f1e
1 file changed
tools/html.py
@@ -2,6 +2,7 @@
2
__author__ = 'zhanghe'
3
4
import re
5
+import json
6
7
8
def replace_html(input_html, reg_expression=r'', replace_text=''):
@@ -82,15 +83,19 @@ def read_file(file_path):
82
83
return f.read()
84
85
-def read_file_each_line(file_path):
86
+def read_file_each_line(file_path, file_type='json'):
87
"""
88
逐行读取文件
89
:param file_path:
90
+ :param file_type:
91
:return:
92
93
with open(file_path, 'r') as f:
94
for each_line in f:
- yield each_line
95
+ if file_type == 'json':
96
+ yield json.loads(each_line)
97
+ if file_type == 'csv':
98
+ yield each_line
99
100
101
def save_file(file_path, text, save_type='w'):
0 commit comments