mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: read excel faster
This commit is contained in:
@@ -273,9 +273,9 @@ async def upload_excel(session: SessionDep, file: UploadFile = File(...)):
|
||||
for sheet_name in sheet_names:
|
||||
tableName = f"{sheet_name}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}"
|
||||
sheets.append({"tableName": tableName, "tableComment": ""})
|
||||
df_temp = pd.read_excel(save_path, nrows=5)
|
||||
non_empty_cols = df_temp.columns[df_temp.notna().any()].tolist()
|
||||
df = pd.read_excel(save_path, sheet_name=sheet_name, engine='calamine', usecols=non_empty_cols)
|
||||
# df_temp = pd.read_excel(save_path, nrows=5)
|
||||
# non_empty_cols = df_temp.columns[df_temp.notna().any()].tolist()
|
||||
df = pd.read_excel(save_path, sheet_name=sheet_name, engine='calamine')
|
||||
insert_pg(df, tableName, engine)
|
||||
|
||||
# os.remove(save_path)
|
||||
|
||||
Reference in New Issue
Block a user