The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Auto-update Google Calendar from CSV

Automatically updating Google Calendar from a CSV file involves a few steps, primarily using Google Apps Script to parse the CSV and create calendar events. Below is a step-by-step guide to help automate the process.


Step 1: Prepare Your CSV File

Your CSV file should be structured with headers, such as:

pgsql
Subject,Start Date,Start Time,End Date,End Time,Description,Location Meeting,2025-06-01,10:00 AM,2025-06-01,11:00 AM,Project discussion,Office

Ensure it’s saved on your Google Drive.


Step 2: Upload CSV to Google Drive

  1. Open Google Drive.

  2. Upload your CSV file.

  3. Note the filename; you’ll need it in the script.


Step 3: Create a Google Apps Script

  1. Go to Google Apps Script.

  2. Create a new project.

  3. Replace the default code with the script below:

javascript
function importCSVtoCalendar() { const calendarName = 'Your Calendar Name'; // Replace with your calendar name const fileName = 'events.csv'; // Replace with your CSV file name const calendar = CalendarApp.getCalendarsByName(calendarName)[0]; if (!calendar) { Logger.log('Calendar not found!'); return; } const file = DriveApp.getFilesByName(fileName); if (!file.hasNext()) { Logger.log('CSV file not found!'); return; } const csvContent = file.next().getBlob().getDataAsString(); const rows = Utilities.parseCsv(csvContent); for (let i = 1; i < rows.length; i++) { const [title, startDate, startTime, endDate, endTime, description, location] = rows[i]; const startDateTime = new Date(`${startDate} ${startTime}`); const endDateTime = new Date(`${endDate} ${endTime}`); calendar.createEvent(title, startDateTime, endDateTime, { description: description, location: location }); } Logger.log('Events imported successfully!'); }

Step 4: Run the Script

  1. Click the disk icon to save.

  2. Click the clock icon to open “Triggers.”

  3. Add a trigger to run importCSVtoCalendar daily or hourly.

  4. Authorize the script to access your Google Calendar and Drive.


Optional: Use Google Sheets Instead of CSV on Drive

If you want more flexibility and editing capabilities:

  1. Open a new Google Sheet.

  2. Go to File > Import and upload your CSV.

  3. Use this code instead:

javascript
function importFromSheetToCalendar() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const calendarName = 'Your Calendar Name'; // Update accordingly const calendar = CalendarApp.getCalendarsByName(calendarName)[0]; if (!calendar) { Logger.log('Calendar not found!'); return; } const data = sheet.getDataRange().getValues(); for (let i = 1; i < data.length; i++) { const [title, startDate, startTime, endDate, endTime, description, location] = data[i]; const start = new Date(`${startDate} ${startTime}`); const end = new Date(`${endDate} ${endTime}`); calendar.createEvent(title, start, end, { description: description, location: location }); } Logger.log('Events created from sheet!'); }

Security and Limitations

  • Make sure your calendar and file names are unique to avoid confusion.

  • The script must be authorized once; after that, automation can proceed.

  • If you rerun the script, it does not check for duplicates. You can add a condition using the event title and date to skip already-added entries.


Enhancements

  • Add a timestamp column to avoid re-adding events.

  • Use unique identifiers for updates instead of only adding new events.

  • Integrate Google Forms to auto-generate CSV entries.


By leveraging Google Apps Script and Drive integration, this automation allows seamless updates to your Google Calendar from a regularly updated CSV file without manual intervention.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About