fusetools.gsuite_tools.GSheets¶
-
class
fusetools.gsuite_tools.GSheets[source]¶ Bases:
objectFunctions for interacting with Google Sheets.
Methods
- param spreadsheet_id
Adds a tab to a Google Sheet.
- param spreadsheet_id
- param spreadsheet_id
clear_google_sheet_dataCreates a GSheets authenticated credentials object.
Deletes data from a Google Sheet.
Adds a tab to a Google Sheet.
- param spreadsheet_id
Freezes the rows of a given Google Sheet.
Gets data from a Google Sheet.
- param include_grid_data
Get the names and IDs of tabs for a given Google Sheet.
- param spreadsheet_id
Creates a Google Sheet in one’s GSuite account.
sort_google_sheet- param spreadsheet_id
Uploads a Pandas DataFrame to a Google Sheet.
Updates a google spreadsheet cell with a value.
-
classmethod
add_google_sheet_comment(spreadsheet_id, tab_id, note_contents, start_row_idx, end_row_idx, start_col_idx, end_col_idx, credentials, req_limit=1)[source]¶ - Parameters
spreadsheet_id –
tab_id –
credentials –
- Returns
-
classmethod
add_google_sheet_tab(spreadsheet_id, tab_name, credentials, req_limit=1)[source]¶ Adds a tab to a Google Sheet.
- Parameters
spreadsheet_id – Id of Google Sheet to add tab to.
tab_name – Name of the tab to be added.
credentials – GSuite credentials object.
- Returns
Result object for API call.
-
classmethod
bulk_add_google_sheet_comment(spreadsheet_id, request_list, credentials, req_limit=1)[source]¶ - Parameters
spreadsheet_id –
tab_id –
credentials –
- Returns
-
classmethod
bulk_update_cell_background_color(spreadsheet_id, credentials, request_list, req_limit=1)[source]¶ - Parameters
spreadsheet_id –
sheet_id –
row_idx_start –
row_idx_end –
col_idx_start –
col_idx_end –
credentials –
dimension –
- Returns
-
classmethod
create_service_serv_acct(member_acct_email, token_path)[source]¶ Creates a GSheets authenticated credentials object.
- Parameters
member_acct_email – GSuite service acct email address.
token_path – Path to GSuite authentication token.
- Returns
Return GSheets authenticated credentials object.
-
classmethod
delete_google_sheet_data(spreadsheet_id, sheet_id, idx_start, idx_end, credentials, dimension='ROWS', req_limit=1)[source]¶ Deletes data from a Google Sheet.
- Parameters
spreadsheet_id – ID of spreadsheet to update.
idx_start – Starting index of row/column for range to delete.
idx_end – Ending index of row/column for range to delete.
credentials –
dimension –
- Returns
-
classmethod
delete_google_sheet_tab(spreadsheet_id, tab_id, credentials, req_limit=1)[source]¶ Adds a tab to a Google Sheet.
- Parameters
spreadsheet_id – Id of Google Sheet to add tab to.
tab_name – Name of the tab to be added.
credentials – GSuite credentials object.
- Returns
Result object for API call.
-
classmethod
drop_duplicates(spreadsheet_id, sheet_id, credentials, dup_idx_start, dup_idx_end, row_idx_start, row_idx_end, col_idx_start, col_idx_end, rows_columns='COLUMNS', req_limit=1)[source]¶ - Parameters
spreadsheet_id –
sheet_id –
credentials –
dup_idx_start –
dup_idx_end –
row_idx_start –
row_idx_end –
col_idx_start –
col_idx_end –
rows_columns –
- Returns
-
classmethod
freeze_rows_cols(spreadsheet_id, tab_id, freeze_idx, credentials, rows=True, req_limit=1)[source]¶ Freezes the rows of a given Google Sheet.
- Parameters
rows –
freeze_idx –
spreadsheet_id – Id of Google Sheet to retrieve.
tab_id – Id of tab to modify.
freeze_row – Spreadsheet row to freeze.
credentials – GSuite credentials object.
- Returns
Result object for API call.
-
classmethod
get_google_sheet(spreadsheet_id, range_name, credentials, tab_name=False, req_limit=1)[source]¶ Gets data from a Google Sheet.
- Parameters
spreadsheet_id – Id of Google Sheet to retrieve.
range_name – Row/Column of Sheet range to retrieve (ex: A1:A99).
tab_name – Name of tab to pull data from (optional).
credentials – GSuite credentials object.
- Returns
Pandas DataFrame of retrieved data.
-
classmethod
get_google_sheet_metadata(spreadsheet_id, credentials, include_grid_data=False, ranges=False, req_limit=1)[source]¶ - Parameters
include_grid_data –
spreadsheet_id –
credentials –
ranges –
- Returns
-
classmethod
get_google_sheet_tabs(spreadsheet_id, credentials, req_limit=1)[source]¶ Get the names and IDs of tabs for a given Google Sheet.
- Parameters
spreadsheet_id – ID of spreadsheet to update.
credentials – GSuite credentials object.
- Returns
Names and IDs of tabs for a given Google Sheet.
-
classmethod
group_sheet_cols_rows(spreadsheet_id, tab_id, start_idx, end_idx, credentials, rows_columns='ROWS', req_limit=1)[source]¶ - Parameters
spreadsheet_id –
tab_id –
start_idx –
end_idx –
credentials –
rows_columns –
- Returns
-
classmethod
make_google_sheet(ss_name, credentials, req_limit=1)[source]¶ Creates a Google Sheet in one’s GSuite account.
- Parameters
ss_name – Name of the Google Sheet to be created.
credentials – GSuite credentials object.
- Returns
Id of newly created Google Sheet.
-
classmethod
update_cell_background_color(spreadsheet_id, sheet_id, row_idx_start, row_idx_end, col_idx_start, credentials, color_dict, cell_or_row='CELL', col_idx_end=False, req_limit=1)[source]¶ - Parameters
spreadsheet_id –
sheet_id –
row_idx_start –
row_idx_end –
col_idx_start –
col_idx_end –
credentials –
dimension –
- Returns
-
classmethod
update_google_sheet_df(spreadsheet_id, df, data_range, credentials, header=False, req_limit=1)[source]¶ Uploads a Pandas DataFrame to a Google Sheet.
- Parameters
spreadsheet_id – ID of spreadsheet to update.
df – Pandas DataFrame to update spreadsheet with.
data_range – Spreadsheet range to insert DataFrame into.
credentials – GSuite credentials object.
- Returns
API response.
-
classmethod
update_google_sheet_val(spreadsheet_id, tab_id, val, row, col, credentials, req_limit=1)[source]¶ Updates a google spreadsheet cell with a value.
- Parameters
spreadsheet_id – Id of spreadsheet to update.
tab_id – Id of spreadsheet tab to update.
val – Value to update spreadsheet cell with.
row – Row of cell to update.
col – Column of cell to update.
credentials – GSuite credentials object.
- Returns
API response.