npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodered-contrib-google-sheets-to-json-stream

v1.0.4

Published

This Node-RED custom node lets you consume google sheets spreadsheets on demand.

Downloads

32

Readme

nodered-contrib-google-sheets-to-json-stream

This Node-RED custom node lets you consume google sheets spreadsheets on demand.

Build Status

Why

My inspiration for creating this module was that the popular node-red-contrib-google-sheets puts all the spreadsheet data in memory overloading Node.js and causing crashes while working with big sets of data (such as 10K+ sheets lines).

It also doesn't automatically set the sheet range nor parse data to JSON nor allow you to filter only the columns you want.

Solution and features

This module nodered-contrib-google-sheets-to-json-stream came to solve these problems by processing data on demand and providing a good developer experience.

Once you add your google sheets credentials and put the spreadSheetId, it:

  • auto completes fields listing all sheets in the spreadsheet
  • automatically sets the range of lines and columns available in the sheets
  • parses the available columns (using the sheet's first line) into JSON
  • processes items on demand (currently process 500 items per time if the range is bigger than 500)
  • in the status, shows how many lines were processed vs how many is missing
  • if you trigger this module twice, stops the current processing

Demo

Node-RED flow

Configuration

Auth

To setup auth this node uses a google service account:

Create a new service account from This Page

Download a JSON credentials object for the service account.

Give that account access to the sheets API.

Share your sheet with the email address of the service account eg [email protected]

credits: I got this piece of info from node-red-contrib-google-sheets

Preparing your sheet

  1. This module use the your sheet's first line to determine what columns the JSON will have
    • Make sure your sheet won't have blank lines in the beggining
  2. This module gets range from the A1 until the line google sheets api returns but sometimes empty lines are in the end
    • Make sure you delete all blank lines in the end of the file to avoid processing empty fields
  3. If you spreadsheet contains blank items, the google API might skip this line

Sheets

The sheet ID can be found in the URL of your google sheet, for example in https://docs.google.com/spreadsheets/d/1UuVIH2O38XK0TfPMGHk0HG_ixGLtLk6WoBKh4YSrDm4/edit#gid=0

Where the ID will be 1UuVIH2O38XK0TfPMGHk0HG_ixGLtLk6WoBKh4YSrDm4/edit#gid=0

Example

You an checkout the examples in ./examples

[{"id":"d652ac160cab2b75","type":"inject","z":"node-456d53ee","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":60,"wires":[["c3338b4dcfe5389b"]]},{"id":"c3338b4dcfe5389b","type":"sheets-to-json-stream","z":"node-456d53ee","config":"node-44ef3d66","sheetId":"","sheetList":"","sheetListValues":"","range":"","columns":"","name":"","x":180,"y":100,"wires":[["e5933f1826546203"]]},{"id":"e5933f1826546203","type":"debug","z":"node-456d53ee","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":200,"y":140,"wires":[]}]

Dependencies

  • It uses the "@googleapis/sheets": "^9.0.0" and "google-auth-library": "^9.11.0"

Contributing

Contributions are always welcome, consider opening an issue first and discuss with the community before opening a pull request

See CONTRIBUTING.md to learn how you can run all tests before changing the code