谷歌电子表格的dict包装

dictsheet的Python项目详细描述


以dict方式管理您的电子表格。一个易于使用的google电子表格python api。按行管理工作表中的信息。基于gspread

功能:

  • 以dict方式管理电子表格
  • 获取/设置工作表映射
  • 更新行或行中的元素。
  • 在电子表格中迭代行。

要求

  • python 2.6+或python 3+,gspread

安装

pip install dictsheet

基本用法

  1. [从google开发者控制台获取oauth2凭据](http://gspread.readthedocs.org/en/latest/oauth2.html
  2. 获取工作表标题。
  3. 开始使用听写表

示例代码

import gspread
from oauth2client.service_account import ServiceAccountCredentials
from dictsheet import DictSheet

# The Credential file obtained from Google
CREDENTIAL_FILE = 'My Projecthah-xxxxxxx.json'
#Title of the sheet
SHEET_NAME = u'titleOfTheSheet'

# Create credentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIAL_FILE, scope)
# Use gspread to connect to Google Spread Sheet
gc = gspread.authorize(credentials)
sh = gc.open(SHEET_NAME)
wks = sh.get_worksheet(0)

# Initialize dictsheet
dict_wks = DictSheet(wks=wks)

# Basic usage
# Get mapping
print dick_wks.mapping

# Set mapping
map = {"name":1, "phone":2, "address":3}
dict_wks.mapping = map

# Appending
dict_wks.append({"name": "Chandler Huang","phone": 987654321})

# Updating (2 is the row number)
dict_wks.update({2: {"name": "Kelly"}, 6:{"phone": 12345}})

# Iterating
for idx, dict_data in dict_wks.items():
print idx, ' : ',dict_data

# Clearing a row
dict_wks[4].clear()

贡献者

黄昌德,李赞德

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
正则表达式Java使用关键字拆分字符串   Neo4j Java API模式索引范围查找?   java访问JButton[]   java如何混淆tomcat日志文件中的请求属性   apache运行CGI Java程序   java从一个Eclipse插件开始,我如何通过编程使Eclipse编辑某个文件?   从php中的SQL数据库到Java中的多个值作为单独的变量   java如何在多个osgi捆绑包之间共享资源   datetime Java time,无法从历元秒解析年份   java无法在安卓应用程序中使用morpho指纹扫描仪设备捕获指纹   java使用groovy/ratpack发送电子邮件   javascript在jsp页面中添加验证,但在控制台中仍然显示一些错误   java如何修复com。mysql。jdbc。DocsConnectionPropsHelper   java AlertDialog dispatchTouchEvent