burnash / burnash/gspread

Manipulate range output using a dictionary instead of lists [FEATURE_REQUEST]

Open
#582 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.5k
Forks
979
PR merge metrics
No merged PRs in 30d

Description

Hello,

Sometimes while using gspread I need to manipulate a bacth of cells from a range but to make it easier and more efficient to manipulate these cells I convert the output from the `range` method to a dicionary.

I think a method to get the output from `range` as dictionary with optional parameters to identify how the key should be setted would be a valuable feature. An example of how this would work is below.

```python
worksheet.range(1, 1, 7, 2, as_map=None) # default
[, ...]

worksheet.range(1, 1, 7, 2, as_map='rows') # rows are the keys
{1: ,
2: ...
....
}

worksheet.range(1, 1, 7, 2, as_map='rows-cols') # rows are the keys 'external' keys and columns the 'internal' keys
{1:
1: ,
2: ...
....
}

worksheet.range(1, 1, 7, 2, as_map='tuple') # (row, col) are the keys
{(1, 1): , ...}
```

If the gspread community thinks this is valuable I would love to make a PR implementing this feature. Thank you for the attention.

Contributor guide

Open the contributing guide

Research direction

Start at the Worksheet.range entry point described in the issue and review how its current list output is documented and tested. Define the supported dictionary key modes and their behavior, then implement the feature with coverage for the default output and each requested mapping form. Done means range still returns the existing list by default and produces predictable row, row-column, and tuple mappings when requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.