node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

Can't use 'title' as a column heading

Open pwalsh opened this issue 12 years ago • 5 comments

We discovered the hard way here https://github.com/okfn/opendatacensus/issues/473 that any data key called "title" is stripped out when adding a row to a spreadsheet, because of this line:

https://github.com/theoephraim/node-google-spreadsheet/blob/master/index.js#L102

Obviously, this extends to "id" and "content" too.

The removal of these fields is probably because of a perceived clash with these names in the XML format for Spreadsheets, being:

<entry gd:etag='"S0wCTlpIIip7ImA0X0QI"'>
  <id>https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId</id>
  <updated>2006-11-17T18:23:45.173Z</updated>
  <category scheme="http://schemas.google.com/spreadsheets/2006"
term="http://schemas.google.com/spreadsheets/2006#list"/>
  <title type="text">Bingley</title>
  <content type="text">Hours: 10, Items: 2, IPM: 0.0033</content>
  <link rel="self" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId"/>
 <link rel="edit" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId/version"/>
  <gsx:name>Bingley</gsx:name>
  <gsx:hours>20</gsx:hours>
  <gsx:items>4</gsx:items>
  <gsx:ipm>0.0033</gsx:ipm>
</entry>

But, seeing as spreadsheet data is namespace by 'gsx:' anyway, it is not necessary.

I'll be happy to make a pull request to fix this issue.

pwalsh avatar Nov 02 '14 10:11 pwalsh

Each row object has its keys from the spreadsheet, but also has some other data on it as well, and id and title are being used in that data.

We'd have to change around the data structure a bit to do this without breaking things...

theoephraim avatar Apr 27 '15 05:04 theoephraim

Sure, we discussed that last year here: https://github.com/theoephraim/node-google-spreadsheet/pull/17

If I get back to working on Node with Google Spreadsheets, I'd help fix this, but I'm not there at the moment. Still, it is a bummer that the library, which is otherwise very useful, fails on such an issue.

pwalsh avatar Apr 27 '15 07:04 pwalsh

Yah I would appreciate if it at least threw a warning.

contextlimit avatar Nov 12 '15 04:11 contextlimit

+1

rohitcmu avatar Mar 19 '17 02:03 rohitcmu

I've just a published a new version of this module which is a complete rewrite using Google's V4 Sheets API (v3 is being deprecated on March 3, 2020). YOU MUST MIGRATE IF YOU ARE STILL USING THIS PACKAGE!

Docs available here - https://theoephraim.github.io/node-google-spreadsheet

I do believe this issue should be fixed in the new version. Please test it out and if you find that there is still a problem, reopen the issue.

Thanks! 😄

theoephraim avatar Feb 03 '20 18:02 theoephraim