第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在python中使用gspread import_csv函數(shù)時(shí)找不到文件

在python中使用gspread import_csv函數(shù)時(shí)找不到文件

慕碼人8056858 2021-07-13 13:01:00
我在 python 中使用 gspread 包。我嘗試將 csv 導(dǎo)入 Google 電子表格,但出現(xiàn)錯(cuò)誤。我的代碼如下:import gspreadfrom oauth2client.service_account import ServiceAccountCredentialsspreadsheet_id = '1tFhK2-zebkG1fZFF6Xe5LHyONkh97ANOkcf'scopes = [    'https://spreadsheets.google.com/feeds',    'https://www.googleapis.com/auth/drive']creds = ServiceAccountCredentials.from_json_keyfile_name('./credentials.json', scopes=scopes)client = gspread.authorize(creds)file = open('test_csv.csv',mode='r')csv = file.read()file.close()client.import_csv(spreadsheet_id, csv)我得到的錯(cuò)誤是:---------------------------------------------------------------------------APIError                                  Traceback (most recent call last)<ipython-input-264-eb5d4ce7bc69> in <module>()----> 1 client.import_csv(spreadsheet_id, csv)~/anaconda3/lib/python3.6/site-packages/gspread/client.py in import_csv(self, file_id, data)    238                 'convert': True    239             },--> 240             headers=headers    241         )    242 ~/anaconda3/lib/python3.6/site-packages/gspread/client.py in request(self, method, endpoint, params, data, json, files, headers)     77             return response     78         else:---> 79             raise APIError(response)     80      81     def list_spreadsheet_files(self):APIError: { "error": {  "errors": [   {    "domain": "global",    "reason": "notFound",    "message": "File not found: 1tFhK2-zebkG1fZFF6Xe5LHyONkh97ANOkcf",    "locationType": "other",    "location": "file"   }  ],  "code": 404,  "message": "File not found: 1tFhK2-zebkG1fZFF6Xe5LHyONkh97ANOkcf" }}但是,當(dāng)我嘗試直接在單元格上讀取或?qū)懭耄╱pdate_cell例如使用函數(shù))時(shí),我沒有收到任何錯(cuò)誤,因此電子表格確實(shí)存在并且我可以在其上書寫。特別import_csv是拋出錯(cuò)誤。我已經(jīng)通過谷歌驅(qū)動(dòng)器網(wǎng)絡(luò)界面創(chuàng)建了谷歌表。然后,我在電子表格的授權(quán)郵件中添加了來自 credential.json (blabla@blabla-220209.iam.gserviceaccount.com) 的 client_email。有什么建議嗎?
查看完整描述

3 回答

?
蝴蝶刀刀

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊

確保您使用的是最新版本的 gspread。例如,與 Google Colab 捆綁在一起的那個(gè)已經(jīng)過時(shí)了:

!pip install --upgrade gspread

gs.csv_import為我修復(fù)了錯(cuò)誤。


查看完整回答
反對(duì) 回復(fù) 2021-07-27
  • 3 回答
  • 0 關(guān)注
  • 234 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)