All Projects → revolunet → spreadsheet-to-json

revolunet / spreadsheet-to-json

Licence: other
Convert Google Spreadsheets to JSON using Javascript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to spreadsheet-to-json

gsheet to arb
Import translations (ARB/Dart) from Google Sheets
Stars: ✭ 21 (-60.38%)
Mutual labels:  google-spreadsheet
citybook
Create a resource directory from a contact spreadsheet.
Stars: ✭ 21 (-60.38%)
Mutual labels:  google-spreadsheet
php-google-spreadsheet-api
PHP library for read/write access to Google spreadsheets via the version 3 API.
Stars: ✭ 38 (-28.3%)
Mutual labels:  google-spreadsheet
import-products-from-gsheet-for-woo-importer
Import products from Google spreadsheet by standard woocommerce import.
Stars: ✭ 16 (-69.81%)
Mutual labels:  google-spreadsheet
google docs-ruby
A library which allows you to edit your spreadsheets with pleasure
Stars: ✭ 18 (-66.04%)
Mutual labels:  google-spreadsheet
GoogleAppsScripts
A repository for my google scripts (GS).
Stars: ✭ 50 (-5.66%)
Mutual labels:  google-spreadsheet
foorgol
⛄ Google API client (or one the Discworld, the Ephebian God of Avalanches).
Stars: ✭ 16 (-69.81%)
Mutual labels:  google-spreadsheet
SPREAD
Spread visualizes how viruses and other pathogens are spreading in time and space. It creates compellable shareable, interactive and time-animated visualization.
Stars: ✭ 9 (-83.02%)
Mutual labels:  spread
gspread-formatting
Complete cell formatting support for Google spreadsheets via gspread package.
Stars: ✭ 121 (+128.3%)
Mutual labels:  google-spreadsheet
OntoMaton
OntoMaton facilitates ontology search and tagging functionalities within Google Spreadsheets.
Stars: ✭ 35 (-33.96%)
Mutual labels:  google-spreadsheet
use-google-spreadsheet
react hook for using google spreadsheet as a data table (API endpoint)
Stars: ✭ 106 (+100%)
Mutual labels:  google-spreadsheet
ad localize
ADLocalize is a simple way to manage your localization files. Supported wording sources : CSVs and Google Sheets. Localization file generation available for iOS, Android, JSON (i18next), YAML and Java properties
Stars: ✭ 22 (-58.49%)
Mutual labels:  google-spreadsheet
adamant-tradebot
Free market-making software for cryptocurrency projects and exchanges. Makes trade volume, maintains spread and liquidity/depth, set price range, and builds live-like dynamic order book.
Stars: ✭ 113 (+113.21%)
Mutual labels:  spread
Learn To Send Email Via Google Script Html No Server
📧 An Example of using an HTML form (e.g: "Contact Us" on a website) to send Email without a Backend Server (using a Google Script) perfect for static websites that need to collect data.
Stars: ✭ 2,718 (+5028.3%)
Mutual labels:  google-spreadsheet
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+18337.74%)
Mutual labels:  google-spreadsheet
Social-Media-Monitor
Automatically monitor and log fan counters from social media(Facebook Pages, Twitter, Instagram, YouTube, Google+, OneSignal, Alexa) using APIs to Google Spreadsheet. Very useful for website admins and social media managers.
Stars: ✭ 36 (-32.08%)
Mutual labels:  google-spreadsheet
google-spreadsheet-cli
📊 CLI for reading and writing data into Google Spreadsheet
Stars: ✭ 51 (-3.77%)
Mutual labels:  google-spreadsheet
budget-cli
Manage your Google budget spreadsheets from terminal.
Stars: ✭ 30 (-43.4%)
Mutual labels:  google-spreadsheet
node-sheets
read rows from google spreadsheet with google's sheets api
Stars: ✭ 16 (-69.81%)
Mutual labels:  google-spreadsheet
meteor-google-spreadsheets
Google Spreadsheets for Meteor
Stars: ✭ 53 (+0%)
Mutual labels:  google-spreadsheet

spreadsheet-to-json

npm license github-issues Circle CI build status

nodei.co

Convert Google Spreadsheets to JSON using Javascript

Uses the google-spreadsheet library to fetch data.

The final JSON is based on sheets names and column titles and finally looks like this :

{
  "Customers": [
    {
      "name": "Sony",
      "country": "Japan"
    },
    {
      "name": "Renault",
      "country": "France"
    }
  ],
  "Invoices": [
    {
      "id": "F0001",
      "totalAmount": "12367.12"
    },
    {
      "id": "F0002",
      "totalAmount": "4398.2"
    }
  ]
}

This can be useful when you want people edit spreadsheets and need to work with the data.

Install

npm i --save spreadsheet-to-json

QuickStart

extractSheets can use node callback pattern or async/await.

const { extractSheets } = require("spreadsheet-to-json");

// optional custom format cell function
const formatCell = (sheetTitle, columnTitle, value) => value.toUpperCase();

extractSheets(
  {
    // your google spreadhsheet key
    spreadsheetKey: "abch54Ah75feBqKGiUjITgE9876Ypb0yE-abc",
    // your google oauth2 credentials or API_KEY
    credentials: require("./google-generated-creds.json"),
    // optional: names of the sheets you want to extract
    sheetsToExtract: ["Customers", "Invoices"],
    // optional: custom function to parse the cells
    formatCell: formatCell
  },
  function(err, data) {
    console.log("Customers: ", data.Customers);
    console.log("Invoices: ", data.Invoices);
  }
);

see ./example.js

Authentification

The credentials key can either be a API_KEY string or a service account object.

API Key

You can create an API key here : https://console.developers.google.com/apis/credentials

Be sure to restrict it to Google Drive API

Google service account

Create a credentials.json file for your app here : https://console.developers.google.com/

  • create a new project
  • enable the Drive API
  • in credentials, select create new credentials then service account and save the generated JSON. (privately)
  • then give the JSON contents to the credentials parameter in the extractSheets call.

Share the target google spreadsheet with the client_email from the credentials.json.

Tests

extractSheet should produce correct data

✓ sheet should have 5 rows
✓ row should have 4 properties
✓ row should have correct properties
✓ name should be Johnny
✓ id should be 1

formatCell

✓ names should not be equal
✓ name should be uppercased
✓ id should be 1

extractSheets should produce correct data

✓ data should have 3 sheets
✓ sheets should have correct names
✓ Private sheet should not be exported
✓ Customers should have 5 rows
✓ Customers properties names should equal id,name,location,Exotic_ Col-NAME
✓ Invoices should have 9 rows
✓ Invoices properties names should equal ref,amount
✓ Leads should have 9 rows
✓ Leads properties names should equal id,estimate,ref

open invalid spreadsheet should return empty data

✓ invalid should have no rows

columns with exotic names should be handled correctly

✓ Exotic column name should exist in output
✓ Exotic column name should be renamed in data
✓ Exotic column name should be handled correctly


total:     21
passing:   21
duration:  1.9s

Author

Julien Bouquillon [email protected] http://github.com/revolunet

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].