This document provides step-by-step instructions for setting up and running a TypeScript script that transfers data from a JSON file to a Notion database. Follow these instructions to get your project up and running.
Get the Notion API key here. You'll need this key for authentication.
Share your Notion database and extract the database ID from the shared URL. You will use this ID to interact with your Notion database programmatically.
https://www.notion.so/fer6ff3d5fcs3dff1d2134349192cc?v=4rf43545...
|---------Database ID----------|
In your Notion workspace, add the integration to your target database. Make sure to configure the appropriate permissions (read and write access) for the integration.
Rename the .env.example
file to .env
and enter your Notion API key and database key.
Open the projectConfig.ts
file and set the project season and project info according to your project requirements.
Use the following command to install the necessary packages for your TypeScript script:
pnpm install
Download the XLSX files from your Google Docs, which contains the data you want to transfer to Notion.
Perform any necessary data cleaning or formatting on the downloaded XLSX files to ensure that it's ready for conversion to JSON.
Use your preferred method or library to convert the cleaned XLSX files to CSV files.
Use an online service or a library (e.g., convertcsv.com) to convert the CSV files to JSON files. Name the JSON files as normal-applicants.json
and beginner-applicants.json
.
Move the generated JSON files to the src
folder in your project directory.
Run the following command to merge the two JSON files into a single file called applicants.json
:
pnpm merge
Download the notion database for the project members of the previous projects as a csv file and convert that file into JSON format. Paste this JSON into a file called past-applicants.json
within the src
folder.
Run the script using the following command:
pnpm exe
This will execute your TypeScript script and transfer the data from the applicants.json
file to the configured Notion database.
If the notion database is in a workspace other than the CFC workspace, you can copy-paste it into the CFC workspace. In particular, select the database, press Ctrl+C
, switch to the appropriate place in the CFC workspace, and then press Ctrl+V
.
EZ