Giter VIP home page Giter VIP logo

node-ss2json's Introduction

node-ss2json

npm version Test

Convert Google Spreadsheet contents to JSON. Also update Google spreadsheet from JSON data.

install

% npm install ss2json

help

% ss2json --help
Usage: ss2json [options] [command]

Options:
  -V, --version     output the version number
  -h, --help        output usage information

Commands:
  get [options]
  update [options]

get

% ss2json get --help
Usage: get [options]

Options:
  -a, --auth [AUTH_JSON_FILE_PATH]  JSON path for Google's authentication
  -i, --id [SPREADSHEET_ID]         Google Spreadsheet ID
  -n, --name [SHEET_NAME]           Sheet name in Google Spreadsheet
  -h, --help

update

% ss2json update --help
Usage: ss2json update [options]

Options:
  -a, --auth [AUTH_JSON_FILE_PATH]  JSON path for Google's authentication
  -i, --id [SPREADSHEET_ID]         Google Spreadsheet ID
  -n, --name [SHEET_NAME]           Sheet name in Google Spreadsheet
  -d, --data [DATA_JSON_FILE_PATH]  JSON file path for update data
  --autoAddSheet                    Add when there was no sheet.
  -h, --help                        output usage information

Command example

Get the data from the spreadsheet and write it to data.json.

% ss2json get \
    -a AUTH_JSON_FILE_PATH \
    -i SPREADSHEET_ID \
    -n SHEET_NAME > ./data.json

You can also edit data.json to update the spreadsheet.

% ss2json update \
    -a AUTH_JSON_FILE_PATH \
    -i SPREADSHEET_ID \
    -n SHEET_NAME \
    -d ./data.json

Usage example of Node.js API

get

const ss2json = new (require('ss2json'))()

ss2json.convert({
  authJsonPath: 'JSON path for Google\'s authentication',
  spreadsheetId: 'Google Spreadsheet ID',
  sheetName: 'Sheet name in Google Spreadsheet'
}).then((data) => {
  console.log(data)
}).catch((err) => {
  console.error(err)
})

update

const ss2json = new (require('ss2json'))()

ss2json.update({
  authJsonPath: 'JSON path for Google\'s authentication',
  spreadsheetId: 'Google Spreadsheet ID',
  sheetName: 'Sheet name in Google Spreadsheet',
  values: [
    // 'Update data'
    {  key1: 'value1', key2: 'value2' },
    {  key1: 'value3', key2: 'value4' },
    ...
  ],
  autoAdd: true // If true, the sheet will be added automatically if it doesn't exist.
}).then((result) => {
  console.log(result)
})

AUTH_JSON_FILE_PATH / authJsonPath

Use GCP service account credentials. You first need to create a service account, download its json key.

node-ss2json's People

Contributors

9renpoto avatar abetomo avatar dependabot[bot] avatar vicentedealencar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-ss2json's Issues

create new worksheets?

after learning concepts from google-spreadsheet (another npm package), I've tried out yours and got amazed by how much more streamlined the workflow has now become. Kudos!

By the way, is there some way to create new worksheets?

ss2json doesn't properly bundle

Great package! Thank you.

I'm having issues trying to bundle using either webpack, broswerify, or rollup (see error from browserify below). Is it not intended to be used outside of a server environment?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.