BramLeo commited on
Commit
dbf5679
Β·
verified Β·
1 Parent(s): bccaf5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -34,10 +34,15 @@ def initialize_settings(model_path):
34
  # Fungsi untuk mengunduh file CSV terbaru dari Google Drive
35
  def download_csv_from_drive():
36
  csv_url = "https://drive.google.com/uc?id=1UIx369_8GlzPiKArMVg8v-IwC6hYTYA0" # Ganti dengan ID file terbaru
37
- output_csv = "bahandokumen/data.csv"
 
38
 
 
 
 
 
39
  if os.path.exists(output_csv):
40
- os.remove(output_csv) # Hapus file lama
41
 
42
  print("πŸ”„ Mengunduh file CSV terbaru...")
43
  try:
@@ -48,10 +53,10 @@ def download_csv_from_drive():
48
  print("❌ Gagal mengunduh file. Cek kembali link Google Drive.")
49
  except Exception as e:
50
  print(f"❌ Terjadi kesalahan saat mengunduh file: {e}")
51
-
52
  return output_csv
53
 
54
- # Fungsi untuk menyimpan file ke Hugging Face Spaces
55
  def save_to_huggingface():
56
  src = "bahandokumen/data.csv"
57
  dst = "/home/user/app/bahandokumen/data.csv" # Jalur sesuai dengan HF Spaces
 
34
  # Fungsi untuk mengunduh file CSV terbaru dari Google Drive
35
  def download_csv_from_drive():
36
  csv_url = "https://drive.google.com/uc?id=1UIx369_8GlzPiKArMVg8v-IwC6hYTYA0" # Ganti dengan ID file terbaru
37
+ output_folder = "bahandokumen"
38
+ output_csv = os.path.join(output_folder, "data.csv") # Path lengkap ke dalam folder
39
 
40
+ # Pastikan folder bahandokumen/ ada
41
+ os.makedirs(output_folder, exist_ok=True)
42
+
43
+ # Hapus file lama jika ada
44
  if os.path.exists(output_csv):
45
+ os.remove(output_csv)
46
 
47
  print("πŸ”„ Mengunduh file CSV terbaru...")
48
  try:
 
53
  print("❌ Gagal mengunduh file. Cek kembali link Google Drive.")
54
  except Exception as e:
55
  print(f"❌ Terjadi kesalahan saat mengunduh file: {e}")
56
+
57
  return output_csv
58
 
59
+ # Fungsi untuk menyimpan file ke jalur yang sesuai di Hugging Face Spaces
60
  def save_to_huggingface():
61
  src = "bahandokumen/data.csv"
62
  dst = "/home/user/app/bahandokumen/data.csv" # Jalur sesuai dengan HF Spaces