Skip to content

Commit 5a66952

Browse files
#REQ_DEV
Prompt Category: Requirement Development Prompt: extract_data.py Finally use the Target sheet https://docs.google.com/spreadsheets/d/1FEqiDqqPfb9YHAWBiqVepmmXj22zNqXNNI7NLGCDVak/edit?gid=0#gid=0 and see that all the required columns along with Mean Rating, Overall Rating, Result and Unique Id are filled in the final sheet. Clear the data in the target sheet before filling new data. And if Result is "Ok", fill the cell color Green. If Result is "Not Ok", fill the cell color "Red" User Observation: The target google sheet was not filled . There is a bug in the code Response ID: 890d48e7-5db4-4c65-ac18-6341795c0908
1 parent f97b790 commit 5a66952

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

app.log

+27
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,30 @@ Exception: API Error
109109
2025-03-13 18:25:36,260 - INFO - Calculated mean ratings
110110
2025-03-13 18:25:36,261 - INFO - Calculated results and color mapping
111111
2025-03-13 18:25:36,262 - INFO - Data retrieval successful
112+
2025-03-13 18:51:41,999 - INFO - Successfully loaded credentials
113+
2025-03-13 18:51:42,000 - INFO - file_cache is only supported with oauth2client<4.0.0
114+
2025-03-13 18:51:42,002 - INFO - Successfully created Google Sheets service
115+
2025-03-13 18:51:48,587 - INFO - Retrieved 144 rows of data
116+
2025-03-13 18:51:48,588 - 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']
117+
2025-03-13 18:51:48,592 - INFO - Successfully filtered required columns
118+
2025-03-13 18:51:48,595 - INFO - Calculated mean ratings
119+
2025-03-13 18:51:48,596 - INFO - Calculated results and color mapping
120+
2025-03-13 18:51:48,597 - INFO - Data retrieval successful
121+
2025-03-13 18:55:17,761 - INFO - Successfully loaded credentials
122+
2025-03-13 18:55:17,762 - INFO - file_cache is only supported with oauth2client<4.0.0
123+
2025-03-13 18:55:17,764 - INFO - Successfully created Google Sheets service
124+
2025-03-13 18:55:20,401 - INFO - Retrieved 144 rows of data
125+
2025-03-13 18:55:20,402 - 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']
126+
2025-03-13 18:55:20,407 - INFO - Successfully filtered required columns
127+
2025-03-13 18:55:20,410 - INFO - Calculated mean ratings
128+
2025-03-13 18:55:20,411 - INFO - Calculated results and color mapping
129+
2025-03-13 18:55:20,412 - INFO - Data retrieval successful
130+
2025-03-13 18:57:05,820 - INFO - Successfully loaded credentials
131+
2025-03-13 18:57:05,822 - INFO - file_cache is only supported with oauth2client<4.0.0
132+
2025-03-13 18:57:05,823 - INFO - Successfully created Google Sheets service
133+
2025-03-13 18:57:08,372 - INFO - Retrieved 144 rows of data
134+
2025-03-13 18:57:08,372 - 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']
135+
2025-03-13 18:57:08,375 - INFO - Successfully filtered required columns
136+
2025-03-13 18:57:08,377 - INFO - Calculated mean ratings
137+
2025-03-13 18:57:08,378 - INFO - Calculated results and color mapping
138+
2025-03-13 18:57:08,379 - INFO - Data retrieval successful

extract_data.py

+96
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,102 @@
1919
)
2020
LOGGER = logging.getLogger(__name__)
2121

22+
def clear_target_sheet():
23+
"""Clear the target spreadsheet"""
24+
try:
25+
scopes = ['https://www.googleapis.com/auth/spreadsheets']
26+
creds = Credentials.from_service_account_file('credentials.json', scopes=scopes)
27+
service = build('sheets', 'v4', credentials=creds)
28+
29+
target_spreadsheet_id = '1FEqiDqqPfb9YHAWBiqVepmmXj22zNqXNNI7NLGCDVak'
30+
range_name = 'Sheet1!A:Z' # Clear all columns
31+
32+
clear_request = service.spreadsheets().values().clear(
33+
spreadsheetId=target_spreadsheet_id,
34+
range=range_name
35+
)
36+
clear_request.execute()
37+
LOGGER.info("Target sheet cleared successfully")
38+
return service
39+
except Exception as error:
40+
LOGGER.error("Error clearing target sheet: %s", str(error))
41+
return None
42+
43+
def write_to_target_sheet(df, service):
44+
"""Write data to target sheet with formatting"""
45+
try:
46+
target_spreadsheet_id = '1FEqiDqqPfb9YHAWBiqVepmmXj22zNqXNNI7NLGCDVak'
47+
48+
# Prepare data for writing
49+
headers = df.columns.tolist()
50+
values = [headers] + df.values.tolist()
51+
52+
# Write data
53+
body = {
54+
'values': values
55+
}
56+
result = service.spreadsheets().values().update(
57+
spreadsheetId=target_spreadsheet_id,
58+
range='Sheet1!A1',
59+
valueInputOption='RAW',
60+
body=body
61+
).execute()
62+
63+
# Apply conditional formatting for Result column
64+
result_column_index = headers.index('Result')
65+
requests = [{
66+
'addConditionalFormatRule': {
67+
'rule': {
68+
'ranges': [{
69+
'sheetId': 0,
70+
'startRowIndex': 1,
71+
'startColumnIndex': result_column_index,
72+
'endColumnIndex': result_column_index + 1
73+
}],
74+
'booleanRule': {
75+
'condition': {
76+
'type': 'TEXT_EQ',
77+
'values': [{'userEnteredValue': 'Ok'}]
78+
},
79+
'format': {
80+
'backgroundColor': {'red': 0.0, 'green': 1.0, 'blue': 0.0}
81+
}
82+
}
83+
}
84+
}
85+
}, {
86+
'addConditionalFormatRule': {
87+
'rule': {
88+
'ranges': [{
89+
'sheetId': 0,
90+
'startRowIndex': 1,
91+
'startColumnIndex': result_column_index,
92+
'endColumnIndex': result_column_index + 1
93+
}],
94+
'booleanRule': {
95+
'condition': {
96+
'type': 'TEXT_EQ',
97+
'values': [{'userEnteredValue': 'Not ok'}]
98+
},
99+
'format': {
100+
'backgroundColor': {'red': 1.0, 'green': 0.0, 'blue': 0.0}
101+
}
102+
}
103+
}
104+
}
105+
}]
106+
107+
service.spreadsheets().batchUpdate(
108+
spreadsheetId=target_spreadsheet_id,
109+
body={'requests': requests}
110+
).execute()
111+
112+
LOGGER.info("Data written to target sheet successfully")
113+
return True
114+
except Exception as error:
115+
LOGGER.error("Error writing to target sheet: %s", str(error))
116+
return False
117+
22118
def get_google_sheet_data():
23119
"""
24120
Retrieves and processes data from a Google Sheet.

0 commit comments

Comments
 (0)