From 8d963f4306dcbd6a15d5feec6142bc7968347df9 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Mon, 24 Jun 2024 12:48:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=8E=E7=A1=AE=E5=90=84=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_review/util/data_util.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/photo_review/util/data_util.py b/photo_review/util/data_util.py index dab8d85..3d581a0 100644 --- a/photo_review/util/data_util.py +++ b/photo_review/util/data_util.py @@ -64,18 +64,19 @@ def handle_date(string): def handle_department(string): result = [] + max_length = 255 if not string: return result - result.append(string) + result.append(string[:max_length]) string_without_num = re.sub(r'\d|一|二|三|四|五|六|七|八|九|十', '', string) if string_without_num != string: - result.append(string_without_num) + result.append(string_without_num[:max_length]) string_without_brackets = re.sub(r'\([^()]*\)|\[[^\[\]]*\]|\{[^\{\}]*\}|([^()]*)', "", string_without_num) if string_without_brackets != string_without_num: - result.append(string_without_brackets) + result.append(string_without_brackets[:max_length]) pure_string = string_without_brackets.split("科")[0] + "科" if pure_string != string_without_brackets: - result.append(pure_string) + result.append(pure_string[:max_length]) return result @@ -83,14 +84,14 @@ def handle_department(string): def handle_name(string): if not string: return "" - return re.sub(r'[^⺀-鿿·]', '', string) + return re.sub(r'[^⺀-鿿·]', '', string)[:30] # 处理医保类型数据 def handle_insurance_type(string): if not string: return "" - return string.replace(":", "").replace(":", "") + return string.replace(":", "").replace(":", "")[:255] # 处理原始数据