refactor: 预留并行修复所需的共享接口
This commit is contained in:
@@ -6,6 +6,8 @@ import csv
|
||||
import io
|
||||
from pathlib import Path
|
||||
|
||||
from app.shared.ids import normalize_id
|
||||
|
||||
_HEADER_KEYS = {
|
||||
"栅格id",
|
||||
"20米栅格id",
|
||||
@@ -19,19 +21,6 @@ _HEADER_KEYS = {
|
||||
}
|
||||
|
||||
|
||||
def normalize_id(value) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
text = str(value).strip().strip("\ufeff")
|
||||
text = text.translate(str.maketrans("0123456789", "0123456789"))
|
||||
text = "".join(text.split())
|
||||
if text.endswith(".0") and text[:-2].isdigit():
|
||||
text = text[:-2]
|
||||
if not text or not text.isdigit():
|
||||
return ""
|
||||
return text
|
||||
|
||||
|
||||
def _header_index(header: list[str]) -> int | None:
|
||||
for index, name in enumerate(header):
|
||||
key = name.strip().lower().replace(" ", "").replace("_", "")
|
||||
|
||||
Reference in New Issue
Block a user