Skip to content

Commit 3e09c97

Browse files
#BUG_FIX
Prompt Category: Bug Fixing Prompt: 2025-03-13 19:00:03,493 - INFO - Successfully filtered required columns /Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py:187: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy filtered_df[col] = pd.to_numeric(filtered_df[col], errors='coerce') /Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py:190: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy filtered_df['Mean Rating'] = filtered_df[rating_columns].mean(axis=1) 2025-03-13 19:00:03,495 - INFO - Calculated mean ratings /Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py:194: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy filtered_df['Difference'] = filtered_df['Mean Rating'] - filtered_df['Overall Rating'] /Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py:202: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy filtered_df['Result'] = filtered_df['Difference'].apply(get_result_status) /Users/surya.sandeep.boda/Desktop/Marscode Zero to One 3/extract_data.py:205: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead Fix the bug in this code. The target Google sheet is not being filled User Observation: 2025-03-13 19:00:05,883 - ERROR - Error writing to target sheet: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1FEqiDqqPfb9YHAWBiqVepmmXj22zNqXNNI7NLGCDVak/values/Sheet1%21A1?valueInputOption=RAW&alt=json returned "Invalid JSON payload received. Unexpected token. 951"], ["", "", "", NaN, NaN, NaN, NaN, ^". Details: "Invalid JSON payload received. Unexpected token. 951"], ["", "", "", NaN, NaN, NaN, NaN, ^"> 2025-03-13 19:00:05,884 - ERROR - Failed to write to target sheet 2025-03-13 19:00:05,885 - ERROR - Failed to process and transfer data Response ID: e2281f3b-f18d-4a84-8944-5b707cf2c634
1 parent 5a66952 commit 3e09c97

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

app.log

+17
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,20 @@ Exception: API Error
136136
2025-03-13 18:57:08,377 - INFO - Calculated mean ratings
137137
2025-03-13 18:57:08,378 - INFO - Calculated results and color mapping
138138
2025-03-13 18:57:08,379 - INFO - Data retrieval successful
139+
2025-03-13 19:00:00,692 - INFO - Successfully loaded credentials
140+
2025-03-13 19:00:00,693 - INFO - file_cache is only supported with oauth2client<4.0.0
141+
2025-03-13 19:00:00,694 - INFO - Successfully created Google Sheets service
142+
2025-03-13 19:00:03,487 - INFO - Retrieved 144 rows of data
143+
2025-03-13 19:00:03,488 - INFO - Available columns in sheet: ['Timestamp', 'Email Address', 'Tool being used', 'Feature used', 'Task Objective', 'Repository Link', 'Repository: Public/Private', 'Repository: Lines of Code', '[Turn 1]: Prompt Category', '[Turn 1]: Prompt', '[Turn 1]: Model Response', '[Turn 1]: Model Response - File [Use only when response is too long]', '[Turn 1]: Observations', '[Turn 1]: Screenshots', '[Turn 2]: Prompt Category', '[Turn 2]: Prompt', '[Turn 2]: Model Response', '[Turn 2]: Model Response - File [Use only when response is too long]', '[Turn 2]: Observations', '[Turn 2]: Screenshot', '[Turn 3]: Prompt Category', '[Turn 3]: Prompt', '[Turn 3]: Model Response', '[Turn 3]: Model Response - File [Use only when response is too long]', '[Turn 3]: Observations', '[Turn 3]: Screenshot', '[Turn 4]: Prompt Category', '[Turn 4]: Prompt', '[Turn 4]: Model Response', '[Turn 4]: Model Response - File [Use only when response is too long]', '[Turn 4]: Observations', '[Turn 4]: Screenshot', '[Turn 5]: Prompt Category', '[Turn 5]: Prompt', '[Turn 5]: Model Response', '[Turn 5]: Model Response - File [Use only when response is too long]', '[Turn 5]: Observations', '[Turn 5]: Screenshot', '[Turn 6]: Prompt Category', '[Turn 6]: Prompt', '[Turn 6]: Model Response', '[Turn 6]: Model Response - File [Use only when response is too long]', '[Turn 6]: Observations', '[Turn 6]: Screenshot', '[Turn 7]: Prompt Category', '[Turn 7]: Prompt', '[Turn 7]: Model Response', '[Turn 7]: Model Response - File [Use only when response is too long]', '[Turn 7]: Observations', '[Turn 7]: Screenshot', 'Context Awareness', 'Context Awareness: Errors', 'Rationale for Context Awareness', 'Output Quality', 'Output Quality: Errors', 'Rationale for Output Quality', 'Autonomy', 'Autonomy: Errors', 'Rationale for Autonomy', 'Iteration Size and Speed', 'Iteration Size and Speed: Errors', 'Rationale for Iteration Size and Speed', 'Experience', 'Experience - Flexibility, Ease of Use and Reliability: Errors', 'Rationale for Experience', 'Loom Recording Link', 'Overall Rating', 'Rationale behind the overall rating', '[Turn 1]: Final Turn?', '[Turn 2]: Final Turn?', '[Turn 3]: Final Turn?', '[Turn 4]: Final Turn?', '[Turn 5]: Final Turn?', '[Turn 6]: Final Turn?', '[Turn 7]: Final Turn?', '[Turn 1]: Turn ID', '[Turn 2]: Turn ID', '[Turn 3]: Turn ID', '[Turn 4]: Turn ID', '[Turn 5]: Turn ID', '[Turn 6]: Turn ID', '[Turn 7]: Turn ID', 'Unique ID']
144+
2025-03-13 19:00:03,493 - INFO - Successfully filtered required columns
145+
2025-03-13 19:00:03,495 - INFO - Calculated mean ratings
146+
2025-03-13 19:00:03,496 - INFO - Calculated results and color mapping
147+
2025-03-13 19:00:03,498 - INFO - file_cache is only supported with oauth2client<4.0.0
148+
2025-03-13 19:00:05,353 - INFO - Target sheet cleared successfully
149+
2025-03-13 19:00:05,883 - ERROR - Error writing to target sheet: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/1FEqiDqqPfb9YHAWBiqVepmmXj22zNqXNNI7NLGCDVak/values/Sheet1%21A1?valueInputOption=RAW&alt=json returned "Invalid JSON payload received. Unexpected token.
150+
951"], ["", "", "", NaN, NaN, NaN, NaN,
151+
^". Details: "Invalid JSON payload received. Unexpected token.
152+
951"], ["", "", "", NaN, NaN, NaN, NaN,
153+
^">
154+
2025-03-13 19:00:05,884 - ERROR - Failed to write to target sheet
155+
2025-03-13 19:00:05,885 - ERROR - Failed to process and transfer data

extract_data.py

+18-12
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,10 @@ def write_to_target_sheet(df, service):
118118
def get_google_sheet_data():
119119
"""
120120
Retrieves and processes data from a Google Sheet.
121-
122-
Returns:
123-
pandas.DataFrame: Processed data from the sheet, or None if an error occurs
124121
"""
125122
try:
126-
# Define the scope and credentials
127-
scopes = ['https://www.googleapis.com/auth/spreadsheets.readonly']
123+
# Update scopes to include write permission
124+
scopes = ['https://www.googleapis.com/auth/spreadsheets'] # Changed from readonly
128125
creds = Credentials.from_service_account_file('credentials.json', scopes=scopes)
129126
LOGGER.info("Successfully loaded credentials")
130127

@@ -222,6 +219,19 @@ def get_result_status(difference):
222219

223220
filtered_df = filtered_df[final_columns]
224221

222+
# Clear target sheet and get service
223+
service = clear_target_sheet()
224+
if service is None:
225+
LOGGER.error("Failed to clear target sheet")
226+
return None
227+
228+
# Write to target sheet
229+
success = write_to_target_sheet(filtered_df, service)
230+
if not success:
231+
LOGGER.error("Failed to write to target sheet")
232+
return None
233+
234+
LOGGER.info("Data successfully written to target sheet")
225235
return filtered_df
226236

227237
except Exception as error:
@@ -231,15 +241,11 @@ def get_result_status(difference):
231241
if __name__ == "__main__":
232242
result_data = get_google_sheet_data()
233243
if result_data is not None:
234-
LOGGER.info("Data retrieval successful")
235-
print("\nFirst 5 rows of retrieved data:")
236-
pd.set_option('display.max_columns', None) # Show all columns
237-
print(result_data.head())
238-
239-
# Print summary statistics
244+
LOGGER.info("Data processing and transfer successful")
245+
print("\nData has been successfully processed and written to the target sheet")
240246
print("\nSummary Statistics:")
241247
print(f"Total Records: {len(result_data)}")
242248
print(f"Ok Results: {len(result_data[result_data['Result'] == 'Ok'])}")
243249
print(f"Not Ok Results: {len(result_data[result_data['Result'] == 'Not ok'])}")
244250
else:
245-
LOGGER.error("Failed to retrieve data")
251+
LOGGER.error("Failed to process and transfer data")

0 commit comments

Comments
 (0)