Skip to content
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

Searching for string and outputting the column. #557

Open
ampifyx opened this issue Jun 8, 2018 · 1 comment
Open

Searching for string and outputting the column. #557

ampifyx opened this issue Jun 8, 2018 · 1 comment

Comments

@ampifyx
Copy link

ampifyx commented Jun 8, 2018

GitHub Issues are for bugs and feature requests.

Please do not post usage questions here. For general support from the community, see StackOverflow: http://stackoverflow.com/questions/tagged/gspread

Issues with usage questions will be closed.

For bugs please provide the following information.

Environment info

Operating System: MacOS
Python version: 3
gspread version: newest

Steps to reproduce

Stack trace or other output that would be helpful

So, I'm trying to make someone input a string and make python search for the string in the first column, if found then output the entire row.

@lavigne958
Copy link
Collaborator

Hi if you want to display the entire row you need to access it.
The dummy way of solving this could be:

  • get all values (all columns, all rows)
  • iterate over all values of column 1, when found print the row

The better way of doing this could be:

  • get the last row, build range name like "A1:A200" in the case last row is number 200
  • get a range of values for only the first column: wks.range("A1:A200")
  • iterate over it, when value matches, get the range for the row: wks.range(rowcols_to_a1(found.row, found.col + nr_column_to_get))
  • Then you have your list of values for the row that matches the first column value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants