Skip to main content

Retrieve and serialize a google sheet into tabular data object for easier list and array manipulations

Project description

Google Sheets Serializer

Author: Paul Shao

a Python library that converts online google sheets into serializable tabular data that can be directly manipulated as Python lists

Version: beta 1.0.6

Get Started:

If you are using this library the first time, please follow the steps below to ensure you have the required libraries and dependencies installed:

  1. Go to Google Developers Link for Sheets API and enable the Google Sheets API through your developer console (It doesn't matter which language for the API you are enabling it from).
  2. Download the generated credentials.json file
  3. Use the command pip show google-sheets-serializer to determine the location of the installed library
  4. Go inside the main directory for serializer package, and put the credentials.json file there.

Basic Usages:

The serializer mainly makes use of 2 objects, Reader and Filter. A Reader is an object that performs the basic operation of reading in a google sheet given its spreadsheet ID and the name of the sheet.

  • To find these two values for a given google sheet, follow the general guidelines below:
  • For example, if I am currently using a spreadsheet, I should be able to get its ID by looking at the current link in my browser:
  • The link should take the form of
https://docs.google.com/spreadsheets/d/<spreadsheetId>/edit#...

Where the placeholder <spreadsheetId> is the spreadsheet ID. The name of the sheet refers to the name of the current tab of the sheet that you are working on. That can be found usually at the bottom left of the google sheets application.

General Methods:

Here are some of the methods currently supported by this library:

To use the package upon installation, import via: import gserializer The main package comes with 2 functions:

  1. create_reader(): creates a Reader object
  2. create_filter(reader): creates a Filter object that takes in Reader object initialized with data

Methods supported by the 2 classes of objects are specified as below:

  1. Reader
    1. read_from_sheet(spreadsheetId, sheetName): takes in a spreadsheet ID and sheet name and returns a Reader object
  2. Filter
    1. Note: the initialization of a Filter object requires a Reader object as an input, and you should generally load the Reader object with the sheets data by calling the method read_from_sheet before using Filter on top of it.
    2. num_cols(): number of columns
    3. num_rows(): number of rows
    4. int_values(): converts all data in the google sheet to be integers if possible
    5. float_values(): converts all data in the google sheet to be floating point numbers if possible
    6. col_names(): a list of all the column names
    7. values(): the data of the google sheet (without the column header)
    8. print_formatted(): prints out all the data in a row-major and aligned order
    9. map(f): applies the function f to all of the data section of the sheet
    10. filter(major_order, f, numerical): filter the google sheet by the predicate function f. Eliminating any row or column that contains at least 1 value that doesn't obey the predicate. Here are some more detailed specifications for each of the parameters:
      1. major_order: can take on values 0 or 1, 0 for row-major, and 1 for column-major
      2. f: the predicate function, should always return a boolean; by default f is set to always return True if not specified
      3. numerical: indicates whether the data needs to be pre-formatted. 0 for leaving it as it is; 1 for converting all data to integers; 2 for converting all data to floating point numbers
    11. reduce(major_order, f, numerical): reduce the google sheet by accumulating and combining cells using the function f. Here are the specifications for each of the parameters:
      1. major_order: can take on values 0 or 1, 0 for row-major, and 1 for column-major
      2. f: the combiner function, should take in 2 arguments (representing the values in 2 adjacent cells, either row-major or column-major)
      3. numerical: indicates whether the data needs to be pre-formatted. 0 for leaving it as it is; 1 for converting all data to integers; 2 for converting all data to floating point numbers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gserializer-1.0.6.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gserializer-1.0.6-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file gserializer-1.0.6.tar.gz.

File metadata

  • Download URL: gserializer-1.0.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for gserializer-1.0.6.tar.gz
Algorithm Hash digest
SHA256 3953e19b744b5cba420da1af8f221d923d9bd4a3eea19a0a0edc6c50c7106992
MD5 540e8e1a4d33010bef10aec455911e83
BLAKE2b-256 aa1bcf66ecdc46a14f8d8080281fadde771ebd1ff9597dda2293672e5a92c0ad

See more details on using hashes here.

File details

Details for the file gserializer-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: gserializer-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for gserializer-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ddc6768ab580c0d412c5fa98d9b052a13c609b6447f8f6738317b2954fff2422
MD5 5f4eb08f0b0c7dd855f1443c29094025
BLAKE2b-256 f14890f0ec6c124284656bf984aea56f1cd6a8b3932bb92cb77c49cb987d1103

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page