1.0.4 • Published 10 months ago

google-sheet-to-csv v1.0.4

Weekly downloads
-
License
GNU General Publi...
Repository
github
Last release
10 months ago

Google Sheet To CSV

Use Google service accounts to download a Google Sheet locally as a csv

Getting started

Install the Library

npm i google-sheet-to-csv

Google Cloud Setup

  1. Create a new project
    • Save the project id
  2. Create a service account
    • Set the role as viewer
    • Save the unique id
  3. Create credentials for service account
  4. Share google sheet with service account
    • Service account email will resemble something along the lines of [projectName]@[projectId].iam.gserviceaccount.com
    • Set the role as viewer

Authorization

There are 2 authorization strategies: credentials.json or ENV variables.

Credentials.json

Move the JSON file to the [rootDir]/tokens directory. If storing in a different location, update the keyFile option.

ENV variables

There are 4 required env variables:

GOOGLE_PROJECT_ID: Defined when creating a project GOOGLE_CLIENT_ID: Unique id of service account GOOGLE_PRIVATE_KEY_ID: Included in credentials.json GOOGLE_PRIVATE_KEY: Included in credentials.json

And one optional env variable:

GOOGLE_PROJECT_NAME: Defined when creating a project

If this is not included, it's extracted from the project id.

Params

namedescriptiontyperequireddefault value
fileIdid of the Google sheetstringtruen/a
keyFileFilepath of the JSON file for service account credentials. Relative to root directory. If JSON file doesn't exist, it will be created.stringfalse"rootDir/tokens/credentials.json"
outputFileFilepath of the outputted CSV file. Relative to root directorystringfalse"rootDir/assets/output.csv"
verboseWhether to display logs or notbooleanfalsefalse
1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago