Anupam251272 commited on
Commit
ae971f9
·
verified ·
1 Parent(s): 4dca928

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -37,28 +37,21 @@ class DataQualitySystem:
37
 
38
  def load_and_process_data(self, file):
39
  try:
40
- file_path = file.name
41
  if file_path.endswith('.csv'):
42
  df = pd.read_csv(file_path)
43
  elif file_path.endswith('.xlsx'):
44
  df = pd.read_excel(file_path)
45
  else:
46
  return None, "Unsupported file format. Please use CSV or XLSX."
47
-
48
- # Initial data checks
49
- metrics = self.initial_data_checks(df)
50
-
51
- # Anomaly detection
52
- df_with_anomalies = self.detect_anomalies(df)
53
-
54
- # Store metrics
55
- self.store_quality_metrics(metrics)
56
-
57
- return df_with_anomalies, "Data processed successfully!"
58
-
59
- except Exception as e:
60
- logging.error(f"Error processing file: {str(e)}")
61
- return None, f"Error processing file: {str(e)}"
62
 
63
  def initial_data_checks(self, df):
64
  metrics = {
 
37
 
38
  def load_and_process_data(self, file):
39
  try:
40
+ file_path = file.name # This should work for both CSV and XLSX files
41
  if file_path.endswith('.csv'):
42
  df = pd.read_csv(file_path)
43
  elif file_path.endswith('.xlsx'):
44
  df = pd.read_excel(file_path)
45
  else:
46
  return None, "Unsupported file format. Please use CSV or XLSX."
47
+ # Continue with the rest of your method
48
+ metrics = self.initial_data_checks(df)
49
+ df_with_anomalies = self.detect_anomalies(df)
50
+ self.store_quality_metrics(metrics)
51
+ return df_with_anomalies, "Data processed successfully!"
52
+ except Exception as e:
53
+ logging.error(f"Error processing file: {str(e)}")
54
+ return None, f"Error processing file: {str(e)}"
 
 
 
 
 
 
 
55
 
56
  def initial_data_checks(self, df):
57
  metrics = {