-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal]: get, get_values filling empty values response from Google Sheet (with expected cells dimension) #947
Comments
Thank you @ccppoo for this very clear explanation. I agree we only need Remember that the method |
@lavigne958 So should it be preserved? or integrated? in case of removing one of it, for later major version, making one of method being deprecated is will be necessary in case of pandas.DataFrame, current default value from example brought from pandas.DataFrame values = worksheet.get_values('A1:C3')
df2 = pd.DataFrame(values, columns=['a', 'b', 'c'], dtype=pd.Int8Dtype)
# or
df2 = pd.DataFrame([[1, '', 3], [4, 5, 6], [7, 8, 9]], columns=['a', 'b', 'c'], dtype=pd.Int8Dtype)
print(df2)
# a b c
# 0 1 3
# 1 4 5 6
# 2 7 8 9 would it be critical for changes? |
I agree by merging the 2 methods into 1. we could:
I just double checked and I was wrong sorry, the method Please don't hesitate to open a new PR with your changes, please read the contributing documentation first 🙂 |
@ccppoo when you are ready for your dev, let me know here and I will plan which release will integrate your changes 😉 |
@lavigne958 I'm not sure I could finish by Dec. 20, for version 5.1.0 🤔 |
No worries, take you time. |
I planned it for the 5.2.0 release, for 1st february, but don't worry if you don't have time we can push it back to later release. |
@lavigne958 I'll work on it, I will feel guilty if I delay over 2 months 🤔 |
can't plan this feature for 5.3.0 it will most probably bring breaking change (at least by the fact that the method must wait for next major release |
Hi @ccppoo are you still working on that feature? |
@lavigne958 @ccppoo thanks for the work on this! I went down the rabbithole to check on this - it would save me quite a headache if it worked. thanks for the awesome proposal! |
Hi @botcs, thanks for the comment! By my evaluation, the work that needs to be done to add this (great) feature would be:
This would work in a similar way to the fairly new kwarg [ It would be great if you feel like contributing. I would look at #1215 for a good idea of what you'd need to do, and the Contributing Guide, and we can offer you any help you need with problems you might come across :) |
@botcs We would still love your help on this, if you are interested. If you no longer wish to, then I will make a PR adding this feature in the coming weeks. |
Hi, Sorry for the long delay, it's summer schools time. I have implemented this for my project, it's just a few lines, I can try to push a PR this week. |
No worries, there's no grand rush. That would be great, if you find any time! :) |
Yes nobrieh if you can make it for 1st of September it goes in release v5.11 if not it goes in the next one, no worries 😉 |
I started work on this in the https://github.com/burnash/gspread/tree/feature/maintain-size branch. However, i.e., sometimes it does not include cell/column indices |
@alifeee hi, see error```bash $ tox -e py -vvv ROOT: 39 D setup logging to NOTSET on pid 274196 [tox/report.py:219] py: 61 I find interpreter for spec PythonSpec(path=/homes/53/csbotos/anaconda3/envs/row/bin/python) [virtualenv/discovery/builtin.py:58] py: 61 I proposed PythonInfo(spec=CPython3.11.4.final.0-64, exe=/homes/53/csbotos/anaconda3/envs/row/bin/python, platform=linux, version='3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65] py: 61 D accepted PythonInfo(spec=CPython3.11.4.final.0-64, exe=/homes/53/csbotos/anaconda3/envs/row/bin/python, platform=linux, version='3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:67] py: 62 D filesystem is case-sensitive [virtualenv/info.py:26] .pkg: 72 I find interpreter for spec PythonSpec(path=/homes/53/csbotos/anaconda3/envs/row/bin/python) [virtualenv/discovery/builtin.py:58] .pkg: 72 I proposed PythonInfo(spec=CPython3.11.4.final.0-64, exe=/homes/53/csbotos/anaconda3/envs/row/bin/python, platform=linux, version='3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:65] .pkg: 72 D accepted PythonInfo(spec=CPython3.11.4.final.0-64, exe=/homes/53/csbotos/anaconda3/envs/row/bin/python, platform=linux, version='3.11.4 (main, Jul 5 2023, 13:45:01) [GCC 11.2.0]', encoding_fs_io=utf-8-utf-8) [virtualenv/discovery/builtin.py:67] .pkg: 73 W _optional_hooks> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi [tox/tox_env/api.py:427] Backend: run command _optional_hooks with args {} Backend: Wrote response {'return': {'get_requires_for_build_sdist': True, 'prepare_metadata_for_build_wheel': True, 'get_requires_for_build_wheel': True, 'build_editable': True, 'get_requires_for_build_editable': True, 'prepare_metadata_for_build_editable': True}} to /tmp/pep517__optional_hooks-_ewkmn0p.json .pkg: 106 I exit None (0.03 seconds) /homes/53/csbotos/github/gspread> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi pid=274202 [tox/execute/api.py:279] .pkg: 107 W get_requires_for_build_sdist> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi [tox/tox_env/api.py:427] Backend: run command get_requires_for_build_sdist with args {'config_settings': None} Backend: Wrote response {'return': []} to /tmp/pep517_get_requires_for_build_sdist-vcqwn1jf.json .pkg: 110 I exit None (0.00 seconds) /homes/53/csbotos/github/gspread> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi pid=274202 [tox/execute/api.py:279] .pkg: 110 W build_sdist> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi [tox/tox_env/api.py:427] Backend: run command build_sdist with args {'sdist_directory': '/homes/53/csbotos/github/gspread/.tox/.pkg/dist', 'config_settings': None} Backend: Wrote response {'return': 'gspread-5.10.0.tar.gz'} to /tmp/pep517_build_sdist-cmy59vyg.json .pkg: 128 I exit None (0.02 seconds) /homes/53/csbotos/github/gspread> python /homes/53/csbotos/anaconda3/envs/row/lib/python3.11/site-packages/pyproject_api/_backend.py True flit_core.buildapi pid=274202 [tox/execute/api.py:279] .pkg: 128 D package .tmp/package/8/gspread-5.10.0.tar.gz links to .pkg/dist/gspread-5.10.0.tar.gz (/homes/53/csbotos/github/gspread/.tox) [tox/util/file_view.py:39] py: 128 W install_package> python -I -m pip install --force-reinstall --no-deps /homes/53/csbotos/github/gspread/.tox/.tmp/package/8/gspread-5.10.0.tar.gz [tox/tox_env/api.py:427] Processing ./.tox/.tmp/package/8/gspread-5.10.0.tar.gz Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: gspread Building wheel for gspread (pyproject.toml) ... done Created wheel for gspread: filename=gspread-5.10.0-py3-none-any.whl size=47030 sha256=5238dd789073a1c5ecc90307b3a38f55944c058e306ff10311e4b5ce670cbd2d Stored in directory: /homes/53/csbotos/.cache/pip/wheels/3f/76/66/0170fc979387e7a07adb0663fb2c0227a2c2f85dd56f979200 Successfully built gspread Installing collected packages: gspread Attempting uninstall: gspread Found existing installation: gspread 5.10.0 Uninstalling gspread-5.10.0: Successfully uninstalled gspread-5.10.0 Successfully installed gspread-5.10.0 py: 712 I exit 0 (0.58 seconds) /homes/53/csbotos/github/gspread> python -I -m pip install --force-reinstall --no-deps /homes/53/csbotos/github/gspread/.tox/.tmp/package/8/gspread-5.10.0.tar.gz pid=274216 [tox/execute/api.py:279] py: 712 W commands[0]> pytest tests/ [tox/tox_env/api.py:427] ================================================================= test session starts ================================================================== platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0 cachedir: .tox/py/.pytest_cache rootdir: /homes/53/csbotos/github/gspread plugins: vcr-1.0.2 collected 107 itemstests/cell_test.py ....... [ 6%] ======================================================================== ERRORS ======================================================================== self = <tests.worksheet_test.WorksheetTest testMethod=test_maintain_size>, client = <gspread.client.BackoffClient object at 0x7f0d838f5410>
tests/worksheet_test.py:21: gspread/client.py:264: in create self = <vcr.patch.VCRRequestsHTTPSConnection/homes/53/csbotos/github/gspread/tests/cassettes/WorksheetTest.test_maintain_size.json object at 0x7f0d83912e50>
E vcr.errors.CannotOverwriteExistingCassetteException: Can't overwrite existing cassette ('/homes/53/csbotos/github/gspread/tests/cassettes/WorksheetTest.test_maintain_size.json') in your current record mode ('none'). .tox/py/lib/python3.11/site-packages/vcr/stubs/init.py:263: CannotOverwriteExistingCassetteException tests/cell_test.py::CellTest::test_merge_cells tests/worksheet_test.py::WorksheetTest::test_clear_tab_color tests/worksheet_test.py::WorksheetTest::test_clear_tab_color tests/worksheet_test.py::WorksheetTest::test_sort -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
Thanks for your work here! :)
You need to run the test online. See the contributing guide. This comment may be helpful for the exact commands I recommend you run. You will also want to run |
superceded by #1289 |
This issue is made to share clear status for solving problem
Point of Contention (1 / 2)
I wrote replies at other issue get_values does not return all data in some scenarios...
But I just want to share some opinions before making a PR.
get()
methodgspread/gspread/worksheet.py
Line 551 in 6d01d7b
and
get_values()
methodgspread/gspread/worksheet.py
Line 254 in 6d01d7b
has no difference but returning value after wrapping with util function
fill_gaps()
gspread/gspread/utils.py
Line 424 in 6d01d7b
so I thought "is it really necessary to separate those two methods?"
Also in Documentation,
Worksheet.get
Workshhet.get_values
has no difference in explanation, because the only difference is, as I mentioned above,
get_values()
returns value got fromget()
after wrapping withfill_gaps()
gspread/gspread/worksheet.py
Line 320 in 6d01d7b
I think it's better to integrate by separating the slight difference by kwargs and it could be more clear
Point of Contention (2 / 2)
Just like issue #910, when people use method like
people those who are first to use this method would have expected
2-D list A1 to C2, even when every cell is empty
just like this:
for more clear examples, see my explanation from issue comment : #910 (comment)
I know google send just empty value, literally no values,
when cells in range is empty like this
gspread/gspread/worksheet.py
Line 595 in 6d01d7b
This could be handled like this from my comment
Conclusion
My proposals are...
get()
andget_value()
toget()
add kwargs like maintain_shape to get expected dimension from given range
The text was updated successfully, but these errors were encountered: