Skip to content
Advertisement

How can I pull data from rows based on the presence of a specific character in a specific column with Google Sheets?

I’m sending API calls to Google sheets to retrieve information like so:

JavaScript

With this, I can retrieve information in any row if there is no value present in column #17. In other words, this essentially reads from the first available row without anything in column #17. If I put an X in column 17, it will read the row below it. This isn’t exactly what I’m looking for.

I’d like to be able to print all values in a row where a specific character like X is present in column 17, and ignore all other rows. I’d then take the data from each row with X present in column 17 and use mail merge to generate a bunch of .docx files. I can easily figure out the second part. Anybody know how to accomplish the first part? (print values in a specific row where X is present in column 17)

Advertisement

Answer

From I'd like to be able to print all values in a row where a specific character like X is present in column 17, and ignore all other rows. I'd then take the data from each row with X present in column 17 and use mail merge to generate a bunch of .docx files. I can easily figure out the second part. Anybody know how to accomplish the first part? (print values in a specific row where X is present in column 17), I believe your goal in this question is as follows.

  • You want to retrieve the filtered rows by the specific value at the column 17 (it’s column “Q”.).
  • You want to achieve this using gspread for python.

In this case, how about the following modification?

Modified script:

JavaScript
  • When this script is run, the rows that the column “Q” is the value of search are retrieved as a 2-dimensional array.

Added:

From the following reply,

This is almost it! How can you print by column only? like, I only want the value from column 3 from the array.. print(values[4]) doesn’t seem to work.

In this case, how about the following sample script?

Sample script:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement