Skip to main content

dftogsheet

A Python module for writing pandas DataFrame objects directly to Google Spreadsheets
dftogsheet is maintained on GitHub and PyPI.

Install dftogsheet

$ pip install dftogsheet

Setup

  1. Enable the Google Sheets API.
  2. Enter a name for your project. This is the name that will be displayed when your app asks for permission to edit your spreadsheets in Google Drive later.
  3. Download credentials.json into project-root-folder/.dftogsheet/credentials/ folder.

Simple usage

import pandas as pd
import dftogsheet

data_frame = pd.DataFrame()
dftogsheet.write_to_sheet(data_frame, spreadsheet_id, sheet_name)

Parameters

There are three mandatory parameters for the above function:

  • data_frame is any pandas DataFrame object.
  • spreadsheet_id is the part of the Google Spreadsheet URL that is between /d/ and /edit.
  • sheet_name is the name of the sheet within the Google spreadsheet. E.g. Sheet1.

Advanced usage

With only the above function, this library pretty much only does one thing. But there is actually a lot more flexibility provided to you if you know what's going on. Please look into the two functions in dftogsheets/__init__.py to understand what is going on under the hood when you run the above code and to understand how you can use the Sheet class and its methods more powerfully. If you have any suggestions, you are always more than welcome to contribute ;)

Changing scopes, valueInputOption, and location of credentials file

What is the valueInputOption? Read this page

These settings are actually controlled by the Config class. A new instance of the Config class with default values is created for you in dftogsheet.write_section_to_sheet so you don't have to think about it for the sample code above. However, it is possible to fully customize these configurations by creating your own config object for your project. Please look into dftogheets/config.py to understand how you can do that.

What's new in version 0.0.7

  • Add Sheet.overwrite() method.
  • Include this method by default.

How can I contribute?

Thanks for asking!
I appreciate everyone who contributes, no matter how you choose to do it.
And if you feel like conforming to my workflow (which I try to stick to), that's great ;)

My workflow

  • Use Gitflow Workflow.
  • Include GitHub issue number in feature and hotfix branch names.
  • If an issue doesn't exist on GitHub, create one.
  • Include branch name in every commit message, even on develop.
  • Only small "one commit" fixes done directly on develop.
  • Commit style: imperitive sentences in all lower case except proper nouns.
  • Merge into develop using pull requests and keeping the entire commmit history.
  • Merge into production squshing commits and keeping only version number in commit message.
  • At some point I would like to automatically publish every release to pushed to production on PyPy.
  • If you add new dependencies, don't use pip freeze > requirements.txt. Add new dependencies manually. Packages we install can install their own dependencies.

Metadata

Release files for dftogsheet 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dftogsheet 0.0.7
File Size Uploaded
dftogsheet-0.0.7.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dftogsheet 0.0.7
File Interpreter ABI Platform
dftogsheet-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / dftogsheet-0.0.7.tar.gz

Download URL dftogsheet-0.0.7.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b60a4235c9e0433d7f31aef66cd863c640ba79b9499e6b054fcdf9e6e6213414
BLAKE2b-256 checksum
How to use checksums
67ba037d62ae995006ecfb2a7685bff06e7d0c5b8374a9af9f91840f95abfc2c
Upload date
Uploaded using Trusted Publishing?
What is 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.1 CPython/3.7.2

Release files / dftogsheet-0.0.7-py3-none-any.whl

Download URL dftogsheet-0.0.7-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c24ce3fee9610b49a00fb8f1d35f0310231446551ae14c42176993544a05060d
BLAKE2b-256 checksum
How to use checksums
a4f73a0b48a52bb53ba4bc6888741e48e420c0e78db3c36f54df315bb1c98286
Upload date
Uploaded using Trusted Publishing?
What is 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.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page