Retrieve and serialize a google sheet into list-like object for much simpler direct manipulations without api calls
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.0
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:
- 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).
- Download the generated
credentials.jsonfile - Use the command
pip show google-sheets-serializerto determine the location of the installed library - Go inside the main directory for serializer package, and put the
credentials.jsonfile 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:
Readerread_from_sheet(spreadsheetId, sheetName): takes in a spreadsheet ID and sheet name and returns a Reader object
Filter- Note: the initialization of a
Filterobject requires aReaderobject as an input, and you should generally load theReaderobject with the sheets data by calling the methodread_from_sheetbefore usingFilteron top of it. num_cols(): number of columnsnum_rows(): number of rowsint_values(): converts all data in the google sheet to be integers if possiblefloat_values(): converts all data in the google sheet to be floating point numbers if possiblecol_names(): a list of all the column namesvalues(): the data of the google sheet (without the column header)print_formatted(): prints out all the data in a row-major and aligned ordermap(f): applies the functionfto all of the data section of the sheetfilter(major_order, f, numerical): filter the google sheet by the predicate functionf. 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:major_order: can take on values 0 or 1, 0 for row-major, and 1 for column-majorf: the predicate function, should always return a boolean; by defaultfis set to always returnTrueif not specifiednumerical: 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
reduce(major_order, f, numerical): reduce the google sheet by accumulating and combining cells using the functionf. Here are the specifications for each of the parameters:major_order: can take on values 0 or 1, 0 for row-major, and 1 for column-majorf: the combiner function, should take in 2 arguments (representing the values in 2 adjacent cells, either row-major or column-major)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
- Note: the initialization of a
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gserializer-1.0.3.tar.gz.
File metadata
- Download URL: gserializer-1.0.3.tar.gz
- Upload date:
- Size: 5.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8886b3829901a0a5417def8eda9e2781ba00f6f0279ffa17e708346a25b0da9
|
|
| MD5 |
e39ab551b6f197293846ced4a35bd83f
|
|
| BLAKE2b-256 |
cb5f0a5e7de7c827363c292d243af147e225daf250b8f522b4f5e8d1904fcb5d
|
File details
Details for the file gserializer-1.0.3-py3-none-any.whl.
File metadata
- Download URL: gserializer-1.0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2be8cf91f59a8f836cf8aa296e75405848db3e173b9de7b7e57c61f82c1de33c
|
|
| MD5 |
c80ab0214b64a32089dc087c23417153
|
|
| BLAKE2b-256 |
7f55033ac122b74ed6bd2a2592292411def7a8212b70768e8290f4d6286d6bb8
|