Parishri07 commited on
Commit
0807a82
·
verified ·
1 Parent(s): 29f9a6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -5,11 +5,16 @@ import pandas as pd
5
  BASE_DIR = "data"
6
 
7
  def get_subfolders(path):
 
8
  try:
9
- return sorted([f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f))])
10
- except FileNotFoundError:
 
 
 
11
  return []
12
 
 
13
  def get_csv_files(path):
14
  try:
15
  return sorted([f[:-4] for f in os.listdir(path) if f.endswith(".csv")])
@@ -59,10 +64,13 @@ with gr.Blocks(title="RetailGenie Navigator") as demo:
59
 
60
  # Logic chaining
61
  country.change(
62
- lambda c: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c)), value=None),
63
- inputs=country,
64
- outputs=state
65
- )
 
 
 
66
 
67
  state.change(
68
  lambda c, s: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s)), value=None),
 
5
  BASE_DIR = "data"
6
 
7
  def get_subfolders(path):
8
+ print(f"📂 Reading subfolders from: {path}")
9
  try:
10
+ folders = sorted([f for f in os.listdir(path) if os.path.isdir(os.path.join(path, f))])
11
+ print(f"✅ Found: {folders}")
12
+ return folders
13
+ except Exception as e:
14
+ print(f"❌ Error reading {path}: {e}")
15
  return []
16
 
17
+
18
  def get_csv_files(path):
19
  try:
20
  return sorted([f[:-4] for f in os.listdir(path) if f.endswith(".csv")])
 
64
 
65
  # Logic chaining
66
  country.change(
67
+ lambda c: (
68
+ print(f"🔽 Selected country: {c}"),
69
+ gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c)), value=None)
70
+ )[1],
71
+ inputs=country,
72
+ outputs=state
73
+ )
74
 
75
  state.change(
76
  lambda c, s: gr.update(choices=get_subfolders(os.path.join(BASE_DIR, c, s)), value=None),