Deletes the CSV file if it exists.
Useful for cleanup or ensuring a fresh start before generating new reports. Does nothing if the file doesn't exist (no error thrown).
Writes a complete schedule's data to the CSV file.
Generates a formatted CSV section containing schedule metadata and a table of user compensation data. Can either create a new file or append to an existing one for multi-schedule reports.
Human-readable name of the PagerDuty schedule
Direct URL to the schedule in PagerDuty
IANA timezone identifier used for OOH calculations
Compensation records for all users in the schedule
If true, appends to existing file; if false, creates new file
Schedule name:,Engineering Primary On-Call
Schedule URL:,https://company.pagerduty.com/schedules/PXXXXXX
Using timezone:,Europe/London
User,Total Compensation (£),Weekdays (Mon-Thu),Weekends (Fri-Sun)
John Doe,275,1,3
Jane Smith,400,2,4
...
append=false: Overwrites any existing fileappend=true: Adds data to end of file with separator lineconst writer = new CsvWriter('august-payments.csv');
// First schedule - create file
writer.writeScheduleData(
'Engineering On-Call',
'https://company.pagerduty.com/schedules/PXXXXXX',
'Europe/London',
engineeringRecords,
false
);
// Second schedule - append
writer.writeScheduleData(
'SRE On-Call',
'https://company.pagerduty.com/schedules/PYYYYYY',
'America/New_York',
sreRecords,
true
);
Writes on-call payment data to CSV files in a Google Sheets compatible format.
This class handles the generation of properly formatted CSV files suitable for import into payroll systems, spreadsheet applications (especially Google Sheets), and audit purposes. It includes automatic directory creation, special character escaping, and support for multi-schedule reports.
Remarks
CSV Format
The generated CSV includes:
Google Sheets Compatibility
Multi-Schedule Support
The class supports appending data from multiple schedules to a single file, automatically separating each schedule's data with blank lines for readability.
Example
See
4180 - CSV Format Specification