【发布时间】:2020-12-26 21:19:54
【问题描述】:
我正在使用 Python 3.9 和以下版本的 Google 表格 ...
gsheets==0.5.1
gspread==3.6.0
我正在尝试将我的 Google 工作表导出为 CSV 文件。在旧版本的 Python 中,我像这样使用 Pandas 模块
import gspread
...
client = gspread.authorize(creds)
sheet = client.open('My_Sheet_name')
# get the third sheet of the Spreadsheet. This
# contains the data we want
sheet_instance = sheet.get_worksheet(3)
records_data = sheet_instance.get_all_records()
records_df = pd.DataFrame.from_dict(records_data)
# view the top records
records_df.to_csv(sys.stdout)
如何在不使用 Pandas 的情况下导出 CSV?我问是因为似乎较新版本的 Python(例如 3.9)还不支持 pandas 模块。
【问题讨论】:
标签: python-3.x csv google-sheets gspread