walter1 commited on
Commit
b7cd2fb
1 Parent(s): 68757a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -107,7 +107,42 @@ def testQA(question):
107
 
108
 
109
 
 
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
 
113
  output = coreName + ': ' + answer
 
107
 
108
 
109
 
110
+ ################### add to the google sheet
111
 
112
+ spreadsheet_id = '1vjWnYsnGc0J6snT67NVbA-NWSGZ5b0eDBVHmg9lbf9s' # Please set the Spreadsheet ID.
113
+ csv_url='https://docs.google.com/spreadsheets/d/' + spreadsheet_id + '/export?format=csv&id=' + spreadsheet_id + '&gid=0'
114
+
115
+ res=requests.get(url=csv_url)
116
+ open('google.csv', 'wb').write(res.content)
117
+ df = pd.read_csv('google.csv')
118
+
119
+ url = 'https://script.google.com/macros/s/AKfycbwXP5fsDgOXJ9biZQC293o6bTBL3kDOJ07PlmxKjabzdTej6WYdC8Yos6NpDVqAJeVM/exec?spreadsheetId=' + spreadsheet_id
120
+ body = {
121
+ "arguments": {"range": "Sheet1!A"+str(len(df)+2), "valueInputOption": "USER_ENTERED"},
122
+ "body": {"values": [[question]]}
123
+ }
124
+ res = requests.post(url, json.dumps(body), headers={'Content-Type': 'application/json'})
125
+
126
+ body = {
127
+ "arguments": {"range": "Sheet1!B"+str(len(df)+2), "valueInputOption": "USER_ENTERED"},
128
+ "body": {"values": [[coreName]]}
129
+ }
130
+ res = requests.post(url, json.dumps(body), headers={'Content-Type': 'application/json'})
131
+
132
+ body = {
133
+ "arguments": {"range": "Sheet1!C"+str(len(df)+2), "valueInputOption": "USER_ENTERED"},
134
+ "body": {"values": [[answer]]}
135
+ }
136
+ res = requests.post(url, json.dumps(body), headers={'Content-Type': 'application/json'})
137
+
138
+ current_time = datetime.datetime.now()
139
+ body = {
140
+ "arguments": {"range": "Sheet1!D"+str(len(df)+2), "valueInputOption": "USER_ENTERED"},
141
+ "body": {"values": [[str(current_time)]]}
142
+ }
143
+ res = requests.post(url, json.dumps(body), headers={'Content-Type': 'application/json'})
144
+ #print(res.text)
145
+ #######################
146
 
147
 
148
  output = coreName + ': ' + answer