You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe the problem you encountered in the DuckDB documentation and include the "Page URL" link shown below.
import duckdb
import os
import pandas as pd
import pyexcel as p
import os
def convert_xls_to_xlsx(file_path):
# Đọc file .xls
sheet = p.get_sheet(file_name=file_path)
# Tạo file .xlsx mới
new_file_path = file_path.replace('.xls', '.xlsx')
# Lưu dữ liệu vào file .xlsx
sheet.save_as(new_file_path)
print(f"Đã chuyển đổi {file_path} thành {new_file_path}")
# Xóa file .xls sau khi chuyển đổi
if os.path.exists(new_file_path):
os.remove(file_path) # Xóa file .xls
print(f"Đã xóa file cũ: {file_path}")
return new_file_path
# Đường dẫn thư mục chứa file .xls và .xlsx của bạn
path_table3 = r'D:\data\CAR\AR_CONTRACT'
#r'D:\workspace\Zeppelin\data_debt_group\data_it\TABLE_LOAN_UPDATE'
# Lặp qua các file trong thư mục và chuyển đổi file .xls thành .xlsx
for file_name in os.listdir(path_table3):
if file_name.endswith('.xls'):
file_path = os.path.join(path_table3, file_name)
convert_xls_to_xlsx(file_path)
def combine_excel_files_duckdb(directory_path):
# Kết nối DuckDB
con = duckdb.connect()
# Cài đặt và nạp tiện ích mở rộng spatial
con.execute("INSTALL spatial;")
con.execute("LOAD spatial;")
data_frames = []
# Lặp qua từng file trong thư mục
for file_name in os.listdir(directory_path):
if file_name.endswith('.xlsx') or file_name.endswith('.xls'):
file_path = os.path.join(directory_path, file_name)
# Đọc file Excel bằng DuckDB với st_read
query = f"SELECT DATA_DATE FROM st_read('{file_path}')"
df = con.execute(query).fetchdf()
data_frames.append(df)
print(f"Đã đọc file: {file_name}")
# Kết hợp tất cả các DataFrame
combined_df = pd.concat(data_frames, ignore_index=True)
return combined_df
InternalException: INTERNAL Error: Failed to bind "ST_Read": Table function must return at least one columnThis error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.For more information, see https://duckdb.org/docs/dev/internal_errors
The text was updated successfully, but these errors were encountered:
Gọi hàm
stm_table3 = combine_excel_files_duckdb(path_table3)
The text was updated successfully, but these errors were encountered: