将Google表格数据导入Redshift

用户名

我正在尝试将保存在Google表格中的数据导入我们的Redshift数据库。我能够按照此链接的指示进行操作:https : //www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in -python.html

是否可以从文件夹中最近添加的google工作表中提取数据(而不是仅指定一个工作表)并写入Redshift表?

这是用来将Google表格数据读入Python的内容:

import gspread
from oauth2client.service_account import ServiceAccountCredentials


# use creds to create a client to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)

# Find a workbook by name and open the first sheet
# Make sure you use the right name here.
sheet = client.open("Copy of Legislators 2017").sheet1

# Extract and print all of the values
list_of_hashes = sheet.get_all_records()
print(list_of_hashes)
来吧

您可以使用驱动器API查询文件给定的时间表是特定类型的范围内添加。此处列出了此类查​​询的所有搜索参数和语法

# Build the Drive service
...

# Query for recent files, with stipulation that their mimetype contains "spreadsheet"
query = "mimeType contains 'spreadsheet' and modifiedTime > '"
query += someDateAsUTC_inRFC_3339_String + "'"

# Execute the query
request = drive.files.list(q=query, .... )
resp = request.execute()
nextPage = resp['nextPageToken']
if resp['files']:
    # Call method to consume files
while nextPage:
    request = drive.files.list_next(request, resp)
    if request:
        resp = request.execute()
        nextPage = resp['nextPageToken']
        if resp['files']:
            # Call method to consume files
    else
        break
# Done

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将CSV数据导入Google表格

将Google表格数据直接导入R

从基于Web的源将XML数据导入Google表格中

如何将数据从Manychat导入Google表格?

如何将网站图形数据导入Google表格

从Google电子表格将数据导入R

如何使用VBA将Google表格中的数据导入Excel

Google 表格导入HTML 表格数据

错误:将数据导入 Redshift 时

Google Cloud Dataprep是否支持将Google云端硬盘表格导入为数据源?

将数据从Google融合表导入Google电子表格

Google表格:如何导入以下数据?

将Excel表格导入数据库

将指数XAO价格导入Google表格

将CSV附件导入Google表格

将 JSON API 导入 Google 表格

使用 Appscript 将 CSV 数据导入 Google 表格,但出现解析错误

使用自动列宽 (v3 API) 从 JavaScript 将数据导入 Google 表格

如何自动将数据从上传的CSV或XLS文件导入Google表格

如何从JSON导入的数据将工作表1附加到Google表格的工作表2中

如何使您的Google表格将导入的JSON数据读取为数字?

使用ImportJSON将数据导入Google表格,是否根据列名选择值输出?

Google App Script 将 CSV 导入到 Google 表格

如何使用 ImportJson 将 Lichess.org 国际象棋数据从此 Json 文件导入 Google 表格?

Google表格导入Excel

Google表格导入范围返回了不正确的数据

将暮光之城数据导入谷歌表格

如何使用 .NET 将数据从 ms sql 导入表格模型

如何将数据从 XML 文件导入 HTML 表格