清理檔案
This commit is contained in:
parent
53b9571e0e
commit
ee2ddca9d3
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -1,45 +0,0 @@
|
||||
import pandas as pd
|
||||
import sqlite3
|
||||
|
||||
# 读取Excel文件
|
||||
excel_file_path = '歌星.xlsx' # 替换为你的Excel文件路径
|
||||
|
||||
# 使用ExcelFile类获取工作表名称
|
||||
excel_file = pd.ExcelFile(excel_file_path, engine='openpyxl')
|
||||
sheet_names = excel_file.sheet_names
|
||||
|
||||
# 选择你想要导入的工作表
|
||||
sheet_to_import = '工作表1' # 替换为你实际的工作表名称
|
||||
df = pd.read_excel(excel_file_path, sheet_name=sheet_to_import, engine='openpyxl')
|
||||
|
||||
# 打印前五行内容
|
||||
print(f"工作表: {sheet_to_import}")
|
||||
print(df.head(), "\n")
|
||||
|
||||
# 连接到SQLite数据库(如果数据库不存在,会自动创建)
|
||||
conn = sqlite3.connect('KSongDatabase.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取列名
|
||||
columns = df.columns.tolist()
|
||||
|
||||
# 动态生成CREATE TABLE语句
|
||||
table_name = 'ArtistLibrary'
|
||||
create_table_sql = f'CREATE TABLE IF NOT EXISTS {table_name} ('
|
||||
create_table_sql += ', '.join([f'"{col}" TEXT' for col in columns])
|
||||
create_table_sql += ')'
|
||||
|
||||
# 执行CREATE TABLE语句
|
||||
cursor.execute(create_table_sql)
|
||||
|
||||
# 将DataFrame的数据写入SQLite表
|
||||
df.to_sql(table_name, conn, if_exists='append', index=False)
|
||||
|
||||
# 验证数据是否插入成功
|
||||
print("数据插入后前五行内容:")
|
||||
query_result = pd.read_sql_query(f"SELECT * FROM {table_name} LIMIT 5", conn)
|
||||
print(query_result)
|
||||
|
||||
# 提交事务并关闭连接
|
||||
conn.commit()
|
||||
conn.close()
|
@ -1,58 +0,0 @@
|
||||
from configparser import ConfigParser
|
||||
|
||||
# Define the base paths for the normal, mouseDown, and mouseOver images
|
||||
normal_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
mouse_down_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
mouse_over_base_path = "themes\\superstar\\歌星\\拼音\\VOD_歌星查詢_拼音查詢(按鍵)-"
|
||||
|
||||
# Create a ConfigParser object
|
||||
config = ConfigParser()
|
||||
config.optionxform = str # Preserve case for option names
|
||||
|
||||
# # Add the section for EnglishLetterButtonImages
|
||||
# config.add_section("EnglishLetterButtonImages")
|
||||
config.add_section("PinYinLetterButtonImages")
|
||||
|
||||
# # Define the QWERTY layout sequence
|
||||
# qwerty_layout = "QWERTYUIOPASDFGHJKLZXCVBNM"
|
||||
|
||||
# Add the image paths dynamically based on the QWERTY layout coordinates
|
||||
for i in range(26):
|
||||
if i < 19:
|
||||
normal_image_number = i + 3
|
||||
mouse_down_image_number = i + 32
|
||||
mouse_over_image_number = i + 3
|
||||
else:
|
||||
normal_image_number = i + 4
|
||||
mouse_down_image_number = i + 33
|
||||
mouse_over_image_number = i + 4
|
||||
|
||||
normal_image = f"{normal_base_path}{normal_image_number:02}.png"
|
||||
mouse_down_image = f"{mouse_down_base_path}{mouse_down_image_number:02}.png"
|
||||
mouse_over_image = f"{mouse_over_base_path}{mouse_over_image_number:02}.png"
|
||||
|
||||
# Add the image paths to the config
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_normal", normal_image)
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_mouseDown", mouse_down_image)
|
||||
config.set("PinYinLetterButtonImages", f"button{i}_mouseOver", mouse_over_image)
|
||||
|
||||
# Add the image paths dynamically for NumberButtonImages
|
||||
# for i in range(10):
|
||||
# normal_image_number = i + 3
|
||||
# mouse_down_image_number = i + 42
|
||||
# mouse_over_image_number = i + 3
|
||||
|
||||
# normal_image = f"{normal_base_path}{normal_image_number:02}.png"
|
||||
# mouse_down_image = f"{mouse_down_base_path}{mouse_down_image_number:02}.png"
|
||||
# mouse_over_image = f"{mouse_over_base_path}{mouse_over_image_number:02}.png"
|
||||
|
||||
# # Add the image paths to the config
|
||||
# config.set("NumberButtonImages", f"button{i}_normal", normal_image)
|
||||
# config.set("NumberButtonImages", f"button{i}_mouseDown", mouse_down_image)
|
||||
# config.set("NumberButtonImages", f"button{i}_mouseOver", mouse_over_image)
|
||||
|
||||
# Write the config to file
|
||||
with open("config.ini", "a", encoding="utf-8") as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
print("config.ini file has been updated successfully.")
|
@ -1,43 +0,0 @@
|
||||
import sqlite3
|
||||
from pypinyin import lazy_pinyin, Style
|
||||
from tqdm import tqdm
|
||||
|
||||
def chinese_to_initials(chinese_str):
|
||||
pinyin_list = lazy_pinyin(chinese_str, style=Style.FIRST_LETTER)
|
||||
initials = ''.join([char.upper() for char in pinyin_list])
|
||||
return initials
|
||||
|
||||
# 連接到 SQLite 資料庫
|
||||
conn = sqlite3.connect('KSongDatabase.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 確保 SongLibrary 表中有 SingerA_pinyin 和 SingerB_pinyin 欄位
|
||||
# cursor.execute('''ALTER TABLE SongLibrary ADD COLUMN 歌星A拼音 TEXT''')
|
||||
# cursor.execute('''ALTER TABLE SongLibrary ADD COLUMN 歌星B拼音 TEXT''')
|
||||
|
||||
# 讀取所有的歌手名稱
|
||||
cursor.execute("SELECT [歌曲編號], [歌星 A], [歌星 B] FROM SongLibrary")
|
||||
rows = cursor.fetchall()
|
||||
|
||||
# 使用 tqdm 來顯示進度條
|
||||
for row in tqdm(rows, desc="Processing songs", unit="song"):
|
||||
song_id, singer_a, singer_b = row
|
||||
if singer_a:
|
||||
singer_a_pinyin = chinese_to_initials(singer_a)
|
||||
else:
|
||||
singer_a_pinyin = None
|
||||
|
||||
if singer_b:
|
||||
singer_b_pinyin = chinese_to_initials(singer_b)
|
||||
else:
|
||||
singer_b_pinyin = None
|
||||
|
||||
# 更新資料庫
|
||||
cursor.execute(
|
||||
"UPDATE SongLibrary SET 歌星A拼音 = ?, 歌星B拼音 = ? WHERE [歌曲編號] = ?",
|
||||
(singer_a_pinyin, singer_b_pinyin, song_id)
|
||||
)
|
||||
|
||||
# 提交變更並關閉資料庫連接
|
||||
conn.commit()
|
||||
conn.close()
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
||||
Selected Theme: themes/default
|
||||
Image Path: C:/Users/Administrator/KSongloverNET/themes/default/0.png
|
||||
|
||||
|
Reference in New Issue
Block a user