Update app.py
Browse files
app.py
CHANGED
|
@@ -19,17 +19,25 @@ if not os.path.exists(dataset_folder):
|
|
| 19 |
# Print available files for debugging
|
| 20 |
print("Available files:", os.listdir(dataset_folder))
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Load all CSV files in the dataset folder
|
| 23 |
dataframes = []
|
| 24 |
for file in os.listdir(dataset_folder):
|
| 25 |
if file.endswith(".csv"): # Check if the file is a CSV
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Merge all CSV files into one DataFrame (only if there are valid files)
|
| 35 |
if dataframes:
|
|
@@ -38,7 +46,6 @@ else:
|
|
| 38 |
print("Warning: No valid CSV files found in the dataset folder.")
|
| 39 |
full_data = pd.DataFrame() # Create an empty DataFrame as a fallback
|
| 40 |
|
| 41 |
-
|
| 42 |
def load_dataset_metadata(dataset_folder):
|
| 43 |
"""Loads metadata from all CSV files in the dataset folder."""
|
| 44 |
dataframes = []
|
|
|
|
| 19 |
# Print available files for debugging
|
| 20 |
print("Available files:", os.listdir(dataset_folder))
|
| 21 |
|
| 22 |
+
import warnings
|
| 23 |
+
|
| 24 |
+
# Ignore dtype warnings
|
| 25 |
+
warnings.simplefilter("ignore", category=pd.errors.DtypeWarning)
|
| 26 |
+
|
| 27 |
# Load all CSV files in the dataset folder
|
| 28 |
dataframes = []
|
| 29 |
for file in os.listdir(dataset_folder):
|
| 30 |
if file.endswith(".csv"): # Check if the file is a CSV
|
| 31 |
+
try:
|
| 32 |
+
df = pd.read_csv(
|
| 33 |
+
os.path.join(dataset_folder, file),
|
| 34 |
+
dtype=str, # Force all columns to be read as strings
|
| 35 |
+
low_memory=False, # Avoids dtype warnings by reading the entire file at once
|
| 36 |
+
encoding="utf-8"
|
| 37 |
+
).fillna('') # Fill NaN values with empty strings
|
| 38 |
+
dataframes.append(df) # Append DataFrame to the list
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print(f"Error reading {file}: {e}")
|
| 41 |
|
| 42 |
# Merge all CSV files into one DataFrame (only if there are valid files)
|
| 43 |
if dataframes:
|
|
|
|
| 46 |
print("Warning: No valid CSV files found in the dataset folder.")
|
| 47 |
full_data = pd.DataFrame() # Create an empty DataFrame as a fallback
|
| 48 |
|
|
|
|
| 49 |
def load_dataset_metadata(dataset_folder):
|
| 50 |
"""Loads metadata from all CSV files in the dataset folder."""
|
| 51 |
dataframes = []
|