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 🙏

© 2026 – Pkg Stats / Ryan Hefner

stream-google-spreadsheet

v0.5.0

Published

Read Google spreadsheet rows as a stream of either JSON or Vinyl objects.

Readme

stream-google-spreadsheet

Read Google spreadsheet rows as a stream of either JSON or Vinyl objects.

Ideally I would use google-worksheet-stream but I wasn't able to get it working so I just moved on. I'll revisit that library before adding any more features to this one though, just in case this one can be discarded.

Usage

The module exposes two functions, each of which returns a Highland stream. The first function, available as the main export, returns each row of the spreadsheet as a JSON object:

var sheetStream = require('stream-google-spreadsheet');

sheetStream(glob, opt)
  .each(console.log);

The output might look something like this:

{
  "id": "https://spreadsheets.google.com/feeds/list/1KX8772HVDFBXYZ7tfOhE-bAuAgSLYABCVkgVwumDEFk/od6/private/full/blah4",
  "title": "E15bFDEX",
  "url": "E15bFDEX",
  "type": "SportsOrganization",
  "name": "Fujian White Crane Kung Fu",
  "mainEntityOfPage": "http://www.fwckungfu.com/",
  "logo": "images/icon/fwckungfu.jpg",
  "legalName": "Fujian White Crane Kung Fu & Tai Chi",
  "sport": "kung fu"
}

The second function wraps these JSON rows in Vinyl objects and is available as src() off the main export:

var gulp = require('gulp');
var sheets = require('stream-google-spreadsheet');
var es = require('vinyl-elasticsearch');

gulp.task('index', function() {
  sheets.src(glob, opt)
    .pipe(es.dest(targetGlob, targetOpt));
});

The Vinyl objects returned from src() will have their path set to the url value in the data, the data property set to the JSON returned, and the contents property set to a Buffer version of the JSON:

{
  "path": "E15bFDEX",
  "data": {
    "title": "E15bFDEX",
    "url": "E15bFDEX",
    "type": "SportsOrganization",
    "name": "Fujian White Crane Kung Fu",
    "mainEntityOfPage": "http://www.fwckungfu.com/",
    "logo": "images/icon/fwckungfu.jpg",
    "legalName": "Fujian White Crane Kung Fu & Tai Chi",
    "sport": "kung fu"
  },
  "contents": ...
}

Whichever function is used, the parameters are the same:

The glob parameter contains one or more spreadsheet keys.

The opt parameter provides the keys used to log in (opt.clientEmail and opt.privateKey), as well as an optional indicator of which worksheet should be loaded (opt.wsNum).

Full Example

To illustrate, here is a complete example that takes rows in a spreadsheet and inserts them into an ElasticSearch index:

var gulp = require('gulp');
var sheets = require('stream-google-spreadsheet');
var es = require('vinyl-elasticsearch');

var env = process.env;

gulp.task('index', function() {
  sheets.src(
    env.SPREADSHEET_KEYS.split(','),
    {
      clientEmail: env.SPREADSHEET_CLIENT_EMAIL,
      privateKey: env.SPREADSHEET_PRIVATE_KEY
    }
  )
    .pipe(es.dest({
        index: env.ELASTICSEARCH_INDEX
      },
      {
        host: env.ELASTICSEARCH_HOST,
        requestTimeout: env.ELASTICSEARCH_REQUEST_TIMEOUT
      }
    ))
    ;
});

Column Names

A column name in a spreadsheet becomes the name of a property in the resulting JSON, which makes for a very convenient mapping. However, the property names are always lowercase, which is not so convenient. As a simple workaround we pass the object keys through LoDash's camelCase function, which means that if we want properties that are camel case in the resulting JSON then we need only use hyphens in the column names in the source spreadsheet.