This scripts create Google Sheets and populates them with URLs saved in an input file (text file)
To begin:
-
Install required packages:
pip install google-auth google-auth-oauthlib google-auth-httplib2 google-api-python-client
-
Enable Google Sheets API
Go to Google Cloud Console: https://console.cloud.google.com/
Create a new project or select an existing one
Enable the Google Sheets API: https://console.cloud.google.com/apis/api/sheets.googleapis.com/
Create credentials (OAuth 2.0 Client ID) for a desktop application
Download the credentials file and rename it to credentials.json
- Prepare your URLs file
Create the input file with your URLs, one per line:
Example:
How to use the script:
Clone this repository and place the input file in the same folder as script.py
Open script.py, go to the main function, and edit the configuration variables: input file name, sheet base name, and number of URLs per sheet (if necessary)
First Run: The script will create sheets normally
Navigate to script.py and run it
Output:
The output of this script will be the files that are created in your Google Sheets.
You can open the files and verify that it has been populated with the URLs.
On failure: It saves progress and you can run it again
Resume: When you run it again, it will detect the progress file and ask if you want to resume
Files:
├── script.py (Source code)
├── credentials.json (Credentials are saved here. This file is downloaded from Google Sheets API)
├── urls.txt (The input file)
├── progress.json (This file saves the progress of the script. It is created and editted automatically wheile running the script)
└── token.json (This file stores the user's access and refresh tokens. It will be created after first run)