When we simply used typewriters to create documents, there were limitations that the typewriters had to make adjustments for.  The first was that your sheet of paper was only so wide, so your typewriter was made to fit that width.  Once you reached the other side you had to move your cartridge back to the left side of the paper and start again.  This action is called carriage return.  The second part was to create a new line.  It’s not enough that the cartridge returned to the correct side of the piece of paper.  You also had to make sure your typing line moved down to the empty space, so you could begin typing on the new line.  This action is called line feed.  

Within programming there are some small bits of code that accomplish those same actions.  In the past the apple operating system used to accomplish both actions (carriage return and line feed), by inputting the code ‘\r’.  Now both the Linux and apple operating systems use ‘\n’.  Microsoft windows uses ‘\r\n’.

var csvfileentry = "Subject,Start Date,Start Time,End Date,End Time,All Day Event,Description,Location,Private";

finalcsv += (csvfileentry + "\r\n");

        
As I discussed yesterday, the first entry I needed in my CSV file for calendar import was the information: Subject,Start Date,Start Time,End Date,End Time,All Day Event,Description, Location,Private.  This information describes to the calendar what each section of data means when it’s being imported.  However for csv formatting this isn’t enough, you also need to designate the carriage return and line feed, in order for each calendar event to be effectively separated.

finalcsv += (csvfileentry + "\r\n");


In order to make this CSV file applicable for all calendar formats, we simply tack on both bits to the end of each calendar entry, as well as the starting entry.  This page on the Google help forums is where I found some helpful information on how to adjust the file to the appropriate format for import.  

Up Next Time: Some simple functions to adjust my time formatting