Lashtw commited on
Commit
b963622
·
verified ·
1 Parent(s): 0c903a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -28,11 +28,11 @@ def main():
28
 
29
  if uploaded_file:
30
  try:
31
- # 讀取CSV檔案,指定欄位類型以保留前導零
32
  df = pd.read_csv(
33
  StringIO(uploaded_file.getvalue().decode('utf-8')),
34
  header=None,
35
- dtype={0: str, 1: str} # 第一欄和第二欄都設為字串
36
  )
37
 
38
  # 自動將第一欄設為姓名,第二欄設為幸運數字
@@ -64,9 +64,10 @@ def main():
64
  progress_bar.progress(progress)
65
  status_text.text(f"正在處理: {index + 1}/{total_rows}")
66
 
67
- # 獲取並處理幸運數字(保持字串格式)
68
- lucky_number = str(row['幸運號碼'])
69
  result = process_number(lucky_number)
 
70
  df.at[index, '查詢結果'] = result
71
 
72
  # 顯示結果
 
28
 
29
  if uploaded_file:
30
  try:
31
+ # 讀取CSV檔案,強制所有欄位為字串以保留前導零
32
  df = pd.read_csv(
33
  StringIO(uploaded_file.getvalue().decode('utf-8')),
34
  header=None,
35
+ dtype=str # 所有欄位都以字串形式讀取
36
  )
37
 
38
  # 自動將第一欄設為姓名,第二欄設為幸運數字
 
64
  progress_bar.progress(progress)
65
  status_text.text(f"正在處理: {index + 1}/{total_rows}")
66
 
67
+ # 獲取幸運數字並確保為7位數
68
+ lucky_number = str(row['幸運號碼']).zfill(7) # 小於7位時補零
69
  result = process_number(lucky_number)
70
+ df.at[index, '幸運號碼'] = lucky_number # 更新為補零後的數字
71
  df.at[index, '查詢結果'] = result
72
 
73
  # 顯示結果