===== google APPs script: transferring name list in google spread sheet to google contacts. ===== A bit for the convenience of organizing a course: 1. Student registration by [[http://docs.google.com/support/bin/answer.py?hl=en&answer=87809|google Forms]] 2. Using the automatically generated name, email address, units, sort each student to a class and store them in google contacts. [[http://www.google.com/google-d-s/scripts/scripts.html |google APPs script, javascripting]] First part is more or less interactive, and second part code is as shown below. //made on 100615 kota Miura // for sorting student list in Google spread sheet (collected by forms), // storing contacts in google contacts and also associate with each class. // function storeNamesInContacts() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var studentDataRange = sheet.getRange("A2:L29"); // For every row of student data, generate an student object. var studentObjects = getRowsData(sheet, studentDataRange); //right hand side is a custom functon in the tutorial var thirdst = studentObjects[2]; var gp1 = ContactsApp.findContactGroup("BasicCourse201006a"); if (gp1 == null) { var gp1 = ContactsApp.createContactGroup("BasicCourse201006a"); } var gp2 = ContactsApp.findContactGroup("BasicCourse201006b"); if (gp2 == null) { var gp2 = ContactsApp.createContactGroup("BasicCourse201006b"); } for (i=0; i 0) { i = fullname.length; } else { key += letter; } } return key; } function LastNameFrom(fullname) { var key = ""; var laststarts = false; for (var i = 0; i < fullname.length; ++i) { var letter = fullname[i]; if (letter == " ") { laststarts = true; } else { if (laststarts ){ key += letter; } } } return key; } At the bottom of above script, "Library" in the link below should be copied and pasted in the same file. http://www.google.com/google-d-s/scripts/reading_spreadsheet_data.html