Dict wrapper for google spreadsheet
Project description
Manage your spreadsheets in dict way. A easy to use Google spreadsheets Python API. Manage information in the sheet in rows. Based on gspread
Features:
Manage the spreadsheet in dict way
Get/Set sheet mapping
Update a row or element(s) in a row.
Iterate rows in a spreadsheet.
Requirements
Python 2.6+ or Python 3+, gspread
Install
pip install dictsheet
Basic Usage
[Obtain OAuth2 credentials from Google Developers Console](http://gspread.readthedocs.org/en/latest/oauth2.html)
Obtain the sheet title.
Start using dictsheet
Sample Code
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()
Contributors
Chandler Huang, Xander Li
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dictsheet-0.0.11.tar.gz
(6.7 kB
view details)
File details
Details for the file dictsheet-0.0.11.tar.gz.
File metadata
- Download URL: dictsheet-0.0.11.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9295188303afff2979c773e98a3ec08cfefb119338995d9cdb5c4d2826ee93d
|
|
| MD5 |
898038759634d931af5cf9f4ef86390e
|
|
| BLAKE2b-256 |
27d48e45dd97c6565f7cfa7a1d7e4440c233592ac7aa0edf8ad2aa3c1807f572
|