Exporting from Google Sheets to Google Contacts

Solution for Exporting from Google Sheets to Google Contacts
is Given Below:

I’m trying to add contacts using a spreadsheet and a script.

So far I was able to copy the script from this user: How to sync google sheets database with google contacts

  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName('Respostas ao formul√°rio 1')
  var headerRows = 1;
  var MaxRow = sheet.getLastRow();
  var dataRange = sheet.getDataRange();
  var data = dataRange.getValues();     
  data.splice(0, headerRows);           

  function addContact() {
    for (var i = 0; i < data.length; i++) {
      var row = data[i];
      var firstName = row[1];
      var lastName = row[2];
      var email = row[3];
      var phone = row[4];
      var group = row[5];
      var job = row[6];
      var address2 = row[7];
         
      contact = ContactsApp.createContact(firstName, lastName, email);
      contact.addPhone(ContactsApp.Field.MOBILE_PHONE, phone);
      
      contact.setNotes(address2)
      contact.addCompany('', job)
      
      var group = ContactsApp.getContactGroup("System Group: My Contacts");
      group.addContact(contact);
   
    }

  }

It works great, but I can’t find out how to add age or to automatically add a label to the contact. Any help would be awesome

You need to create a custom field. Within your code if you add this line I think you’ll get what you need:

contact.addCustomField("Age", '26');

Try to add ” var age = row[8];” under “var address2 = row[7];
“or whereever you want. If you place it other you have to ajust the numbers.

I hope i can help!