1
votes

I'm using the query language to query data from spreadsheet. I would like to retrieve the first row(column headers), how do I do that?

Currently I'm using: select * where ( A = -1 ) , the data in A column is never equal to -1, so it returns only column headers.

Is there a straightforward way to do this?

1

1 Answers

0
votes

You can use query(A:Z, "select * limit 0", 1) meaning: select all, return at most 0 rows. The result is that only the header row is returned (the 3rd parameter is to make it clear there is 1 header row).

But it's not really natural to use query for this purpose. The function array_constrain is provided for the purpose of truncating an array of data. For example,

=array_constrain(A:Z, 1, 1e7)

returns the first row of the given array. (Since no limit on the number of columns is needed, I gave 1e7 = 10,000,000 as the maximal number of columns. A spreadsheet can't even have that many cells.)