Skip to content

Commit

Permalink
Merge pull request #83 from ttsukagoshi/ttsukagoshi-patch-1
Browse files Browse the repository at this point in the history
Update README.md to add screenshots
  • Loading branch information
ttsukagoshi authored Sep 17, 2023
2 parents 1273598 + cf0b644 commit fa36a87
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# csv2gsheets: Create & update Google Sheets files using your local CSV

A Node.js CLI tool to convert local CSV files into Google Sheets files in a designated Google Drive folder. You can choose whether to update an existing Sheets file, or create a new one.
A Node.js CLI tool to convert local CSV files into Google Sheets files in a designated Google Drive folder. You can choose whether to update an existing Sheets file or create a new one.

## What is it for?

Expand All @@ -9,7 +9,7 @@ csv2gsheets is a command-line tool that allows you to create and update Google S
The basic workflow is as follows:

1. Create a configuration file: `c2g init`
You will be asked to specify the path to your local CSV folder, the ID of your Google Drive folder, and some optional settings such as whether to update existing Sheets files with the same name or create new ones. This has to be done only once.
You will be asked to specify the path to your local CSV folder, the ID of your Google Drive folder, and some optional settings, such as whether to update existing Sheets files with the same name or create new ones. This has to be done only once.

2. Convert your CSV files into Google Sheets files: `c2g convert`
Based on the configuration file you created in the previous step, csv2gsheets will convert your local CSV files into Google Sheets files in the designated Google Drive folder.
Expand Down Expand Up @@ -48,44 +48,54 @@ Run `csv2gsheets` to confirm your installation:
c2g --help
```

`c2g` is the shorthand for running `csv2gsheets`. All commands in the following sections will use this shortened version, but they can all be replaced by its full name. For example:
`c2g` is the shorthand for running `csv2gsheets`. All commands in the following sections will use this shortened version but can all be replaced by its full name. For example:

```bash
c2g convert --dry-run
```

is the equivalent to running
is the equivalent of running

```bash
csv2gsheets convert --dry-run
```

#### Updating csv2gheets

New releases will be posted on [the GitHub repository](https://github.com/ttsukagoshi/csv2gsheets). To update your installed version, run:
New releases will be posted on [the GitHub repository](https://github.com/ttsukagoshi/csv2gsheets). To update your installed version, run the following:

```bash
npm update -g csv2gsheets
```

### Create a Google Cloud project and enable the Drive API

csv2gsheets uses the Google Drive API to create and update Google Sheets files. To use the API, you need to create a Google Cloud project and enable the Drive API for it. This is perhaps the most complicated part of the setup process, especially if you are not familiar with Google Cloud.
csv2gsheets uses the Google Drive API to create and update Google Sheets files. To use the API, you need to create a Google Cloud project and enable the Drive API. This is perhaps the most complicated part of the setup process, especially if you are unfamiliar with Google Cloud.

The basic steps are described below, but you can also refer to the [Create a Google Cloud project](https://developers.google.com/workspace/guides/create-project) page in the Google for Developers website for more details. A less detailed, but more practical guide can be found at the [official Node.js quickstart for Google Drive](https://developers.google.com/drive/api/quickstart/nodejs) page. See the sections "Prerequisites" and "Set up your environment" in the webpage.
The basic steps are described below, but you can also refer to the [Google Cloud project](https://developers.google.com/workspace/guides/create-project) page on the Google for Developers website for more details. A less detailed but more practical guide can be found on the [official Node.js quickstart for Google Drive](https://developers.google.com/drive/api/quickstart/nodejs) page. See the sections "Prerequisites" and "Set up your environment" on the webpage.

1. Create a Google Cloud project
Go to the [Google Cloud Console](https://console.cloud.google.com/) and create a new project. You can also click [this link](https://console.cloud.google.com/projectcreate) to go directly to the project creation page.

<img width="767" alt="Screenshot of the page to create a new Google Cloud project" src="https://github.com/ttsukagoshi/csv2gsheets/assets/55706659/d70594c9-8319-4145-b527-49bbf7d01e3e">

2. Enable the Drive API
Go to the [API Library](https://console.cloud.google.com/apis/library) page and enable the Drive API. You can also click [this link](https://console.cloud.google.com/flows/enableapi?apiid=drive.googleapis.com) to go directly to the "Enable Drive API" page.

<img width="943" alt="Screenshot of the Enable API page" src="https://github.com/ttsukagoshi/csv2gsheets/assets/55706659/10a2b973-9dc9-4e54-9631-8b21cc86c3b7">


3. Create the OAuth consent screen
Go to the [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) page and create a new consent screen. You can choose either "Internal" or "External" depending on whether you want to use the tool only for yourself or share it with others. If you choose "External", you will need to add test users. Enter your Gmail address and any other authorized test users' addresses in the "Test users" section.
Go to the [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent) page and create a new consent screen. You can choose "Internal" or "External," depending on whether you want to use the tool only for yourself or share it with others. If you select "External," you must add test users. Enter your Google account and other authorized test users' addresses in the "Test users" section.

<img width="943" alt="Screenshot of the OAuth consent screen where the user is asked to enter test accounts" src="https://github.com/ttsukagoshi/csv2gsheets/assets/55706659/186db13b-e8f2-46b3-be5b-0388468d3bba">

4. Create credentials
Go to the [Credentials](https://console.cloud.google.com/apis/credentials) page and create a new OAuth client ID. Choose "Desktop app" as the application type. You can choose any name you like for the client ID. Save the created credentials as a JSON file named `c2g.creds.json` and save them in your home directory.

<img width="954" alt="Screenshot of the popup that the user will see when they have completed setting their OAuth client ID. The DOWNLOAD JSON button will be available." src="https://github.com/ttsukagoshi/csv2gsheets/assets/55706659/14cd38ec-2308-469a-816a-166333348e5a">


The credentials file saved in your home directory would be something like this:

```
Expand All @@ -96,13 +106,13 @@ C:\Users\your-user-name\c2g.creds.json
/Users/your-user-name/c2g.creds.json
```

Do NOT share this file with anyone else unless you know exactly what you are doing. If you accidentally share it, you can always revoke the credentials by going to the [Credentials](https://console.cloud.google.com/apis/credentials) page and deleting the OAuth client ID you created.
Do NOT share this file with anyone unless you know exactly what you are doing. If you accidentally share it, you can always revoke the credentials by going to the [Credentials](https://console.cloud.google.com/apis/credentials) page and deleting the OAuth client ID you created.

## Usage

### Logging in to Google: `login`

Before converting your CSV file, you will need to log in to Google using an account that has editor-level access to the target Google Drive folder. This is done by running the following command:
Before converting your CSV file, you must log in to Google using an account with editor-level access to the target Google Drive folder. This is done by running the following command:

```bash
c2g login
Expand All @@ -126,7 +136,7 @@ Running the following command will prompt you to answer several questions on how
c2g init
```

This will create a configuration file named `c2g.config.json` in your current working directory, specifying
This will create a configuration file named `c2g.config.json` in your current working directory, specifying:

- the path to your local CSV folder
- the ID of your target Google Drive folder
Expand All @@ -136,15 +146,15 @@ This will create a configuration file named `c2g.config.json` in your current wo

For more information on the configuration file and its values, see the [Configuring csv2gsheets](#configuring-csv2gsheets) section.

Note that you can create as many configuration files in different directories as you want by running `c2g init` in the respective directories. Each directory can have its own target Google Drive folder.
You can create as many configuration files in different directories as you want by running `c2g init` in the respective directories. Each directory can have its own target Google Drive folder.

If you are not yet logged into Google, you can do so by using the `--login` (`-l`) option:

```bash
c2g init --login
```

This is the same as to running `c2g init` and `c2g login` in sequence.
This is the same as running `c2g init` and `c2g login` in sequence.

### Converting CSV files into Google Sheets files: `convert`

Expand All @@ -154,7 +164,7 @@ Convert your CSV files into Google Sheets files by running the following command
c2g convert
```

csv2gsheets will look for the configuration file `c2g.config.json` in the current working directory and convert all CSV files in the specified directory. If you want to specify the path to the configuration file, use the `--config-file-path` (`-c`) option:
csv2gsheets will look for the configuration file `c2g.config.json` in the current working directory and convert all CSV files in the specified directory to Google Sheets. If you want to specify the path to the configuration file, use the `--config-file-path` (`-c`) option:

```bash
c2g convert --config-file-path ./Users/your-user-name/path/to/c2g.config.json
Expand All @@ -178,19 +188,19 @@ Options can be combined:
c2g convert -c ./Users/path/to/c2g.config.json -d -b
```

Note that upload/conversion may take some time depending on the number of files and their sizes. The process is subject to Google's [usage limits](https://developers.google.com/drive/api/guides/limits); you may encounter an error if you try to upload too many files at once.
Note that upload/conversion may take some time, depending on the number of files and their sizes. The process is subject to Google's [usage limits](https://developers.google.com/drive/api/guides/limits); you may encounter an error if you try to upload too many files simultaneously.

### Logging out of Google: `logout`

Once logged in, you will not need to log in again regardless of your current working directory. However, if you want to log out, you can do so by running the following command:
Once logged in, you will not need to log in again, regardless of your current working directory. However, if you want to log out, you can do so by running the following command:

```bash
c2g logout
```

## Configuring csv2gsheets

The configuration file `c2g.config.json` is a JSON file that specifies the following values. You can create a configuration file either by running `c2g init` in the directory where you want to use csv2gsheets, or by manually creating and editing the file on your prefered text editor. In the latter case, make sure to save the file as `c2g.config.json` and designate UTF-8 for text encoding.
The configuration file `c2g.config.json` is a JSON file that specifies the following values. You can create a configuration file by running `c2g init` in the directory where you want to use csv2gsheets or manually creating and editing the file on your preferred text editor. In the latter case, save the file as `c2g.config.json` and designate UTF-8 for text encoding.

| Key | Type | Description | Default Value |
| ---------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
Expand Down

0 comments on commit fa36a87

Please sign in to comment.