python - 使用 gspread 将 CSV 上传到 Google 表格
问题描述
我有一个需要上传到 Google 电子表格的 Json 对象。我已经搜索并阅读了各种资源,但找不到解决方案。有没有办法使用 gspread 将对象或 csv 从本地上传到谷歌电子表格。我宁愿不使用谷歌客户端 api。谢谢
解决方案
您可以使用方法导入 CSV 数据gspread.Client.import_csv
。这是文档中的一个简单示例:
import gspread
# Check how to get `credentials`:
# https://github.com/burnash/gspread
gc = gspread.authorize(credentials)
# Read CSV file contents
content = open('file_to_import.csv', 'r').read()
gc.import_csv('<SPREADSHEET_ID>', content)
这会将您的 CSV 文件上传到带有<SPREADSHEET_ID>
.
笔记
此方法删除所有其他工作表,然后完全替换第一个工作表的内容。
推荐阅读
- javascript - 有没有办法改变(或设置)Expo-Location 的正北?
- node.js - 使用feathersjs oauth调用未处理的拒绝
- laravel - Laravel 与 Google BigQuery
- vba - 访问 VBA TransferText 输出记录乱序
- azure-web-app-service - 什么 Rbac 操作/权限将允许 Azure 应用服务网络访问限制
- apache-spark - spark RangeBetween 如何与降序一起使用?
- python - 用 BS 美化的 Python 正则表达式替换缩进 HTML 的问题
- javascript - Issues accessing Array for a column chart in Javascript
- c++ - 从函数参数复制整数数组 [C++]
- node.js - nodejs 或 express 如何在 Angular 框架中工作?