Package: gserializer
Google Sheets SerializerAuthor: Paul Shaoa Python library that converts online google sheets into serializable tabular data that can be directly manipulated as Python listsVersion: beta 1.0.6Get 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 toGoogle Developers Link for Sheets APIandenable the Google Sheets APIthrough your developer console (It doesn't matter which language for the API you are enabling it from).Download the generatedcredentials.jsonfileUse the commandpip show google-sheets-serializerto determine the location of the installed libraryGo inside the main directory for serializer package, and put thecredentials.jsonfile there.Basic Usages:The serializer mainly makes use of 2 objects,ReaderandFilter. AReaderis an object that performs the basic operation of reading in a google sheet given itsspreadsheet IDand thename 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 thecurrent linkin my browser:The link should take the form ofhttps://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 gserializerThe main package comes with 2 functions:create_reader(): creates aReaderobjectcreate_filter(reader): creates aFilterobject that takes inReaderobject initialized with dataMethods supported by the 2 classes of objects are specified as below:Readerread_from_sheet(spreadsheetId, sheetName): takes in a spreadsheet ID and sheet name and returns a Reader objectFilterNote:the initialization of aFilterobject 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 containsat least 1 valuethat 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 numbersreduce(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