小编Joh*_*est的帖子

CSV 到 Google Sheets python

我有一个 CSV 文件,我想将其放入 Google Sheet 中的 Sheet3 中。我希望有人可以帮助我完成这段代码。我正在使用谷歌API。到目前为止,我已经将 csv 上传到谷歌驱动器。现在我想更改代码以更新sheet3中的特定google工作表而不是创建新工作表。您将在下面找到我用来创建包含 CSV 数据的新工作表的代码。

# Import Csv to Google Drive
import os
import glob

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()           
drive = GoogleDrive(gauth)  

 
# line used to change the directory
os.chdir(r'DIRECTORY OF CSV')

list_of_files = glob.glob('DIRECTORY OF CSV\*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)

upload_file_list = [latest_file]
for upload_file in upload_file_list:
    gfile = drive.CreateFile({'parents': [{'id': 'THE GOOGLE ID'}]}) …
Run Code Online (Sandbox Code Playgroud)

python google-sheets google-sheets-api

2
推荐指数
1
解决办法
4366
查看次数

标签 统计

google-sheets ×1

google-sheets-api ×1

python ×1