Plugin Author
Meitar
(@meitar)
This has been asked quite a few times before and the issue is always that the way you’ve written your shortcode makes it so that the data you expect is simply not there to be consumed by the plugin. Here is your raw data coming from google:
https://docs.google.com/spreadsheets/d/1OLd6zAwL1YZ1R1hgnrdJtbZdPZdJSfEM532asI6Cv3I/gviz/tq?tqx=out:csv
As you can see, the data from Google omits the text in the header, as is to be expected from Google’s Chart Tools datasource protocol.
If you contrast this with the simpler CSV export endpoint, which this plugin uses when you do not supply a query or a chart attribute in your shortcode, you’ll see the full data in the first row as you may expect is there:
https://docs.google.com/spreadsheets/d/1OLd6zAwL1YZ1R1hgnrdJtbZdPZdJSfEM532asI6Cv3I/export?format=csv
The lesson: if you do not need the chart or query attribute, do not use it. If you absolutely do need to use the chart or query attribute, then you have historically had to construct your query in such a way as to ensure that the data you want is considered by Google as data and not as headers, otherwise Google strips out certain headers for you, which is what most people want.
I recently became aware of a new parameter available to the Google Chart Tools datasource API that instructs Google not to strip headers in this fashion, so as of Inline Google Spreadsheet Viewer version 0.13.1 (released today), you can add csv_headers="1" to your shortcode to restore stripped headers like this.
Let me know if, after updating, that does not work for you.
Thank you Meitar. Working like a charm. π
If I use this shortcode I get the query results but no headers (the first row of data is displayed as the column headers):
[gdoc key=”https://docs.google.com/spreadsheets/d/1AS_uvjotrQPAt06IIT3e25qVH7gTRWIYLO-BWHX-xMM/edit#gid=1108019399″ csv_headers=”1″ query= “select * where C contains ‘Sinai’ order by A desc” ]
Am I applying the csv_headers=”1″ incorrectly?
-
This reply was modified 6 years, 1 month ago by
geriebiffle.
-
This reply was modified 6 years, 1 month ago by
geriebiffle.
I had missing headers too. Instead of the one suggestion, and your example:
csv_headers="1"
Per the 0.13.1 Changelog notes, I added the statement without the quotes:
csv_headers=1
and it worked for me.