feat: enhance error logging for file processing in CSV, XLS, and DOC handlers
This commit is contained in:
parent
82a2203be6
commit
0f1d57f0cb
@ -34,6 +34,8 @@ class CsvSplitHandle(BaseSplitHandle):
|
|||||||
file_name = os.path.basename(file.name)
|
file_name = os.path.basename(file.name)
|
||||||
result = {'name': file_name, 'content': paragraphs}
|
result = {'name': file_name, 'content': paragraphs}
|
||||||
try:
|
try:
|
||||||
|
if type(limit) is str:
|
||||||
|
limit = int(limit)
|
||||||
reader = csv.reader(io.TextIOWrapper(io.BytesIO(buffer), encoding=detect(buffer)['encoding']))
|
reader = csv.reader(io.TextIOWrapper(io.BytesIO(buffer), encoding=detect(buffer)['encoding']))
|
||||||
try:
|
try:
|
||||||
title_row_list = reader.__next__()
|
title_row_list = reader.__next__()
|
||||||
|
|||||||
@ -195,6 +195,8 @@ class DocSplitHandle(BaseSplitHandle):
|
|||||||
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
||||||
file_name = os.path.basename(file.name)
|
file_name = os.path.basename(file.name)
|
||||||
try:
|
try:
|
||||||
|
if type(limit) is str:
|
||||||
|
limit = int(limit)
|
||||||
image_list = []
|
image_list = []
|
||||||
buffer = get_buffer(file)
|
buffer = get_buffer(file)
|
||||||
doc = Document(io.BytesIO(buffer))
|
doc = Document(io.BytesIO(buffer))
|
||||||
|
|||||||
@ -46,7 +46,8 @@ class HTMLSplitHandle(BaseSplitHandle):
|
|||||||
|
|
||||||
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
||||||
buffer = get_buffer(file)
|
buffer = get_buffer(file)
|
||||||
|
if type(limit) is str:
|
||||||
|
limit = int(limit)
|
||||||
if pattern_list is not None and len(pattern_list) > 0:
|
if pattern_list is not None and len(pattern_list) > 0:
|
||||||
split_model = SplitModel(pattern_list, with_filter, limit)
|
split_model = SplitModel(pattern_list, with_filter, limit)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -41,6 +41,8 @@ class TextSplitHandle(BaseSplitHandle):
|
|||||||
|
|
||||||
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
|
||||||
buffer = get_buffer(file)
|
buffer = get_buffer(file)
|
||||||
|
if type(limit) is str:
|
||||||
|
limit = int(limit)
|
||||||
if pattern_list is not None and len(pattern_list) > 0:
|
if pattern_list is not None and len(pattern_list) > 0:
|
||||||
split_model = SplitModel(pattern_list, with_filter, limit)
|
split_model = SplitModel(pattern_list, with_filter, limit)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user