Zasha1 commited on
Commit
5736615
·
verified ·
1 Parent(s): 6ce6beb

Update google_sheets.py

Browse files
Files changed (1) hide show
  1. google_sheets.py +7 -5
google_sheets.py CHANGED
@@ -70,17 +70,19 @@ def fetch_call_data(sheet_id, sheet_range="Sheet1!A1:E"):
70
 
71
  # If rows exist, convert to DataFrame
72
  if rows:
 
73
  headers = rows[0]
74
  data = rows[1:]
75
- if not data:
76
- print("No data available in the specified range.")
77
- return pd.DataFrame(columns=headers) # Return DataFrame with headers only
78
  df = pd.DataFrame(data, columns=headers)
 
79
  return df
80
  else:
81
- print("No data available in the Google Sheet.")
82
  return pd.DataFrame()
83
 
84
  except Exception as e:
85
  print(f"Error fetching data from Google Sheets: {e}")
86
- return pd.DataFrame()
 
 
70
 
71
  # If rows exist, convert to DataFrame
72
  if rows:
73
+ # Use the first row as column headers
74
  headers = rows[0]
75
  data = rows[1:]
76
+
77
+ # Create DataFrame
 
78
  df = pd.DataFrame(data, columns=headers)
79
+
80
  return df
81
  else:
82
+ # Return an empty DataFrame if no data
83
  return pd.DataFrame()
84
 
85
  except Exception as e:
86
  print(f"Error fetching data from Google Sheets: {e}")
87
+ # Return an empty DataFrame in case of error
88
+ return pd.DataFrame()