Update google_sheets.py
Browse files- 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 |
-
|
76 |
-
|
77 |
-
return pd.DataFrame(columns=headers) # Return DataFrame with headers only
|
78 |
df = pd.DataFrame(data, columns=headers)
|
|
|
79 |
return df
|
80 |
else:
|
81 |
-
|
82 |
return pd.DataFrame()
|
83 |
|
84 |
except Exception as e:
|
85 |
print(f"Error fetching data from Google Sheets: {e}")
|
86 |
-
|
|
|
|
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()
|