UD Calendar: Creating a CVS file
Follow these directions to submit several of your UD events for the UD Calendar.
CSV File Format
You can create a text file of your events using a text editor, Excel or a database query. It must contain the following fields in the following order:
Title,Start Date,Start time,End Date,End Time,All day event,Categories,Priority,Description
Furthermore, each field has the following constraints:
- Title - must be contained in double quotes
- Start Date, End Date - must be in the format "YYY-MM-DD" and contained in double quotes
- Start Time, End Time - must be in the format "HHH:MM:SS AM/PM" (seconds optional) and contained in double quotes. If there is no start or end time, put empty quotes ("")
- All Day Event - 1 or 0 (not in quotes). If 1, the start and end times should be empty ("")
- Categories - If categories exist in your UD Calendar, you can use them here (in double quotes). If not, make this empty quotes ("")
- Priority - "Low","Medium" or "High" in double quotes
- Description - Any text, in double quotes
Generating compliant .csv files from an existing database
If your calendar data is stored in an SQL-compatible database, you can construct a query to export the data in the proper .csv format. The exact query will vary based on your database's column types and data representation so each application will need a custom query, however the following example can be used as a starting point for your database administrator.
This MySQL example double-quotes any fields that require it, and converts the date stored in the database from 'MM/DD/YYYY' format to the required 'YYYY-MM-DD'. It also sets 'All day event' to 0, 'Categories' to "" and 'Priority' to "Medium" for all records.
SELECT CONCAT("\"",classid,"\"") AS 'Title',
CONCAT("\"",STR_TO_DATE(class_date, '%m/%d/%Y'),"\"") AS 'Start Date',
CONCAT("\"",class_start,"\"") AS 'Start Time',
CONCAT("\"",STR_TO_DATE(class_date, '%m/%d/%Y'),"\"") AS 'End Date',
CONCAT("\"",class_end,"\"") AS 'End Time',
0 AS 'All day event',
"\"\"" AS 'Categories',
"\"Medium\"" AS 'Priority',
CONCAT("\"",description,"\"") AS 'Description'
The resulting table could be exported as .csv.