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

sheets-to-json

v1.0.11

Published

Get your Google Spreadsheets as single JSON with Node.js or command-line

Downloads

2

Readme

Google Spreadsheets fetcher for node.js & CLI

Lightweight & easy-to-use library to get Google Spreadsheets with Node.js or command-line.

  • works ONLY with shared spreadsheets (don't be confused with 'Publish to Web')
  • easy to start using: simple API gives just neccessary options
  • Can be used inside your app via Node.js
  • Or CLI when JSON file with sheets data is all you need

Installation

For CLI (command-line)

npm install -g sheets-to-json

For Node.js

npm install --save sheets-to-json

Before start

You need to get table-Id from spreadsheets you want to obtain:

  • Go to the page with your spreadsheet
  • Check if spreadsheet is shared and availiable by link
  • How to find ID => **https://docs.google.com/spreadsheets/d/ **\*\*\*\***\*YOUR**_ID_**GOES\_\_\_HERE\*\***\*\*\*\*\*** - highlighted is table ID

Usage

CLI

$ gsdata --help
Usage: gsdata <table-id> [filename] [options]

Options:
  -V, --version  output the version number
  -j, --json     Convert TSV to JSON
  -h, --help     output usage information

Notes

  • table-id is required. By calling gsdata 'your-id-goes-here' result will be printed directly in CLI
  • filename is optional. Type the path/to/your/file.json after table-id and result will be written as JSON file.
  • Right now options consists only of -j or --json. Can be used instead of or after filename - converts obtained sheets' data from TSV to JSON (see Examples)

Node.js

import gsdata from 'sheets-to-json';

gsdata({
  // ID from spreadsheet; required.
  tableId: 'your-table-id-goes-here',
  // If you want to save result as file - type in path; optional.
  file: 'path/to/your/data.json',
  // If you want parsed sheet(-s) to be converted from TSV to JSON use this option; optional.
  options: {
    json: true,
  },
});

Notes

  • tableId is required. By calling
gsdata({ tableId: 'your-table-id-goes-here' });

result will be printed in console.

  • filename is optional.
gsdata({
  tableId: 'your-table-id-goes-here',
  file: 'path/to/your/data.json',
});

result will be written as JSON file.

  • Right now options consists only of
options: {
  json: true;
}

Can be used instead of or after file

gsdata({
  tableId: 'your-table-id-goes-here',
  options: {
    json: true,
  },
});

to convert obtained sheets' data from TSV to JSON (see Examples)

Examples

Get JSON with plain TSV data printed into console:

CLI:

$ gsdata 5G9YfhYY******

Node.js:

gsdata({ tableId: '5G9YfhYY******' });

+ data converted from TSV to JSON: CLI:

$ gsdata 5G9YfhYY****** -j

Node.js:

gsdata({
  tableId: '5G9YfhYY******',
  options: {
    json: true,
  },
});

Write JSON with plain TSV data into file:

CLI:

$ gsdata 5G9YfhYY****** path/to/file.json

Node.js:

gsdata({
  tableId: '5G9YfhYY******',
  file: 'path/to/file.json',
});

+ data converted from TSV to JSON: CLI:

$ gsdata 5G9YfhYY****** path/to/file.json -j

Node.js:

gsdata({
  tableId: '5G9YfhYY******',
  file: 'path/to/file.json',
  options: {
    json: true,
  },
});

Features

  • This library is inteneded to work ONLY with shared spreadsheets - it doesn't use any side APIs or packages to fetch data, just plain request as if you did in your browser.
  • It doesn't need any sort of authentication so you don't have to waste your time doing all those side actions. Great for collaboration teams.
  • It's an exporting tool ONLY (can't write anything back to your spreadsheet).
  • ... but it's open for new features! Contact me or send pull request if you have something to bring in.

Author

Roman Shalman

License

GNU General Public License v3.0, see LICENSE